@kubb/plugin-react-query
Version:
React Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for React applications.
772 lines (767 loc) • 28.3 kB
JavaScript
const require_components = require('./components-DkiO4xNZ.cjs');
let __kubb_plugin_oas = require("@kubb/plugin-oas");
__kubb_plugin_oas = require_components.__toESM(__kubb_plugin_oas);
let __kubb_plugin_ts = require("@kubb/plugin-ts");
__kubb_plugin_ts = require_components.__toESM(__kubb_plugin_ts);
let __kubb_plugin_zod = require("@kubb/plugin-zod");
__kubb_plugin_zod = require_components.__toESM(__kubb_plugin_zod);
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
__kubb_plugin_oas_utils = require_components.__toESM(__kubb_plugin_oas_utils);
let __kubb_react = require("@kubb/react");
__kubb_react = require_components.__toESM(__kubb_react);
let __kubb_react_jsx_runtime = require("@kubb/react/jsx-runtime");
__kubb_react_jsx_runtime = require_components.__toESM(__kubb_react_jsx_runtime);
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
__kubb_plugin_client_components = require_components.__toESM(__kubb_plugin_client_components);
let __kubb_plugin_client = require("@kubb/plugin-client");
__kubb_plugin_client = require_components.__toESM(__kubb_plugin_client);
let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
__kubb_plugin_oas_hooks = require_components.__toESM(__kubb_plugin_oas_hooks);
let remeda = require("remeda");
remeda = require_components.__toESM(remeda);
//#region src/generators/queryGenerator.tsx
const queryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
name: "react-query",
Operation({ options, operation }) {
const { plugin: { options: { output } }, pluginManager } = (0, __kubb_react.useApp)();
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
const isMutation = (0, remeda.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([__kubb_plugin_client.pluginClientName]);
const client = {
name: hasClientPlugin ? getName(operation, {
type: "function",
pluginKey: [__kubb_plugin_client.pluginClientName]
}) : getName(operation, { type: "function" }),
file: getFile(operation, { pluginKey: [__kubb_plugin_client.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: [__kubb_plugin_ts.pluginTsName] }),
schemas: getSchemas(operation, {
pluginKey: [__kubb_plugin_ts.pluginTsName],
type: "type"
})
};
const zod = {
file: getFile(operation, { pluginKey: [__kubb_plugin_zod.pluginZodName] }),
schemas: getSchemas(operation, {
pluginKey: [__kubb_plugin_zod.pluginZodName],
type: "function"
})
};
if (!isQuery || isMutation) return null;
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File, {
baseName: query.file.baseName,
path: query.file.path,
meta: query.file.meta,
banner: (0, __kubb_plugin_oas_utils.getBanner)({
oas,
output,
config: pluginManager.config
}),
footer: (0, __kubb_plugin_oas_utils.getFooter)({
oas,
output
}),
children: [
options.parser === "zod" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
root: query.file.path,
path: zod.file.path
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: "fetch",
path: options.client.importPath
}),
hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [client.name],
root: query.file.path,
path: client.file.path
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["RequestConfig", "ResponseErrorConfig"],
path: options.client.importPath,
isTypeOnly: true
}),
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["ResponseConfig"],
path: options.client.importPath,
isTypeOnly: true
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.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__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.QueryKey, {
name: queryKey.name,
typeName: queryKey.typeName,
operation,
pathParamsType: options.pathParamsType,
typeSchemas: type.schemas,
paramsCasing: options.paramsCasing,
transformer: options.queryKey
}),
!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_plugin_client_components.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__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["queryOptions"],
path: importPath
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.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__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["useQuery"],
path: importPath
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [
"QueryKey",
"QueryClient",
"QueryObserverOptions",
"UseQueryResult",
"QueryClient"
],
path: importPath,
isTypeOnly: true
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.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
})
] })
]
});
}
});
//#endregion
//#region src/generators/mutationGenerator.tsx
const mutationGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
name: "react-query",
Operation({ options, operation }) {
const { plugin: { options: { output } }, pluginManager } = (0, __kubb_react.useApp)();
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
const isMutation = !(!!options.query && options.query?.methods.some((method) => operation.method === method)) && (0, remeda.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: [__kubb_plugin_ts.pluginTsName] }),
schemas: getSchemas(operation, {
pluginKey: [__kubb_plugin_ts.pluginTsName],
type: "type"
})
};
const zod = {
file: getFile(operation, { pluginKey: [__kubb_plugin_zod.pluginZodName] }),
schemas: getSchemas(operation, {
pluginKey: [__kubb_plugin_zod.pluginZodName],
type: "function"
})
};
const hasClientPlugin = !!pluginManager.getPluginByKey([__kubb_plugin_client.pluginClientName]);
const client = {
name: hasClientPlugin ? getName(operation, {
type: "function",
pluginKey: [__kubb_plugin_client.pluginClientName]
}) : getName(operation, { type: "function" }),
file: getFile(operation, { pluginKey: [__kubb_plugin_client.pluginClientName] })
};
const mutationOptions = { name: getName(operation, {
type: "function",
suffix: "MutationOptions"
}) };
const mutationKey = {
name: getName(operation, {
type: "const",
suffix: "MutationKey"
}),
typeName: getName(operation, {
type: "type",
suffix: "MutationKey"
})
};
if (!isMutation) return null;
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File, {
baseName: mutation.file.baseName,
path: mutation.file.path,
meta: mutation.file.meta,
banner: (0, __kubb_plugin_oas_utils.getBanner)({
oas,
output,
config: pluginManager.config
}),
footer: (0, __kubb_plugin_oas_utils.getFooter)({
oas,
output
}),
children: [
options.parser === "zod" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
root: mutation.file.path,
path: zod.file.path
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: "fetch",
path: options.client.importPath
}),
!!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [client.name],
root: mutation.file.path,
path: client.file.path
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [
"RequestConfig",
"ResponseConfig",
"ResponseErrorConfig"
],
path: options.client.importPath,
isTypeOnly: true
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.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__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.MutationKey, {
name: mutationKey.name,
typeName: mutationKey.typeName,
operation,
pathParamsType: options.pathParamsType,
typeSchemas: type.schemas,
paramsCasing: options.paramsCasing,
transformer: options.mutationKey
}),
!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_plugin_client_components.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__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["mutationOptions"],
path: importPath
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.MutationOptions, {
name: mutationOptions.name,
clientName: client.name,
mutationKeyName: mutationKey.name,
typeSchemas: type.schemas,
paramsCasing: options.paramsCasing,
paramsType: options.paramsType,
pathParamsType: options.pathParamsType,
dataReturnType: options.client.dataReturnType
}),
options.mutation && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["useMutation"],
path: importPath
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["UseMutationOptions", "QueryClient"],
path: importPath,
isTypeOnly: true
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.Mutation, {
name: mutation.name,
mutationOptionsName: mutationOptions.name,
typeName: mutation.typeName,
typeSchemas: type.schemas,
operation,
dataReturnType: options.client.dataReturnType,
paramsCasing: options.paramsCasing,
pathParamsType: options.pathParamsType,
mutationKeyName: mutationKey.name
})
] })
]
});
}
});
//#endregion
//#region src/generators/infiniteQueryGenerator.tsx
const infiniteQueryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
name: "react-infinite-query",
Operation({ options, operation }) {
const { plugin: { options: { output } }, pluginManager } = (0, __kubb_react.useApp)();
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
const isMutation = (0, remeda.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([__kubb_plugin_client.pluginClientName]);
const client = {
name: hasClientPlugin ? getName(operation, {
type: "function",
pluginKey: [__kubb_plugin_client.pluginClientName]
}) : getName(operation, {
type: "function",
suffix: "infinite"
}),
file: getFile(operation, { pluginKey: [__kubb_plugin_client.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: [__kubb_plugin_ts.pluginTsName] }),
schemas: getSchemas(operation, {
pluginKey: [__kubb_plugin_ts.pluginTsName],
type: "type"
})
};
const zod = {
file: getFile(operation, { pluginKey: [__kubb_plugin_zod.pluginZodName] }),
schemas: getSchemas(operation, {
pluginKey: [__kubb_plugin_zod.pluginZodName],
type: "function"
})
};
if (!isQuery || isMutation || !isInfinite) return null;
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File, {
baseName: query.file.baseName,
path: query.file.path,
meta: query.file.meta,
banner: (0, __kubb_plugin_oas_utils.getBanner)({
oas,
output,
config: pluginManager.config
}),
footer: (0, __kubb_plugin_oas_utils.getFooter)({
oas,
output
}),
children: [
options.parser === "zod" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
root: query.file.path,
path: zod.file.path
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: "fetch",
path: options.client.importPath
}),
hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [client.name],
root: query.file.path,
path: client.file.path
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["RequestConfig", "ResponseErrorConfig"],
path: options.client.importPath,
isTypeOnly: true
}),
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["ResponseConfig"],
path: options.client.importPath,
isTypeOnly: true
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.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__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.QueryKey, {
name: queryKey.name,
typeName: queryKey.typeName,
operation,
paramsCasing: options.paramsCasing,
pathParamsType: options.pathParamsType,
typeSchemas: type.schemas,
transformer: options.queryKey
}),
!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_plugin_client_components.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__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["InfiniteData"],
isTypeOnly: true,
path: importPath
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["infiniteQueryOptions"],
path: importPath
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.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__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["useInfiniteQuery"],
path: importPath
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [
"QueryKey",
"QueryClient",
"InfiniteQueryObserverOptions",
"UseInfiniteQueryResult"
],
path: importPath,
isTypeOnly: true
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.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,
queryParam: options.infinite.queryParam
})
] })
]
});
}
});
//#endregion
//#region src/generators/suspenseQueryGenerator.tsx
const suspenseQueryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
name: "react-suspense-query",
Operation({ options, operation }) {
const { plugin: { options: { output } }, pluginManager } = (0, __kubb_react.useApp)();
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
const isMutation = (0, remeda.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([__kubb_plugin_client.pluginClientName]);
const client = {
name: hasClientPlugin ? getName(operation, {
type: "function",
pluginKey: [__kubb_plugin_client.pluginClientName]
}) : getName(operation, {
type: "function",
suffix: "suspense"
}),
file: getFile(operation, { pluginKey: [__kubb_plugin_client.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: [__kubb_plugin_ts.pluginTsName] }),
schemas: getSchemas(operation, {
pluginKey: [__kubb_plugin_ts.pluginTsName],
type: "type"
})
};
const zod = {
file: getFile(operation, { pluginKey: [__kubb_plugin_zod.pluginZodName] }),
schemas: getSchemas(operation, {
pluginKey: [__kubb_plugin_zod.pluginZodName],
type: "function"
})
};
if (!isQuery || isMutation || !isSuspense) return null;
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File, {
baseName: query.file.baseName,
path: query.file.path,
meta: query.file.meta,
banner: (0, __kubb_plugin_oas_utils.getBanner)({
oas,
output,
config: pluginManager.config
}),
footer: (0, __kubb_plugin_oas_utils.getFooter)({
oas,
output
}),
children: [
options.parser === "zod" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
root: query.file.path,
path: zod.file.path
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: "fetch",
path: options.client.importPath
}),
hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [client.name],
root: query.file.path,
path: client.file.path
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["RequestConfig", "ResponseErrorConfig"],
path: options.client.importPath,
isTypeOnly: true
}),
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["ResponseConfig"],
path: options.client.importPath,
isTypeOnly: true
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.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__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.QueryKey, {
name: queryKey.name,
typeName: queryKey.typeName,
operation,
paramsCasing: options.paramsCasing,
pathParamsType: options.pathParamsType,
typeSchemas: type.schemas,
transformer: options.queryKey
}),
!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_plugin_client_components.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__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["queryOptions"],
path: importPath
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.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__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["useSuspenseQuery"],
path: importPath
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: [
"QueryKey",
"QueryClient",
"UseSuspenseQueryOptions",
"UseSuspenseQueryResult"
],
path: importPath,
isTypeOnly: true
}),
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
name: ["ResponseConfig"],
path: options.client.importPath,
isTypeOnly: true
}),
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.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
})
] })
]
});
}
});
//#endregion
Object.defineProperty(exports, 'infiniteQueryGenerator', {
enumerable: true,
get: function () {
return infiniteQueryGenerator;
}
});
Object.defineProperty(exports, 'mutationGenerator', {
enumerable: true,
get: function () {
return mutationGenerator;
}
});
Object.defineProperty(exports, 'queryGenerator', {
enumerable: true,
get: function () {
return queryGenerator;
}
});
Object.defineProperty(exports, 'suspenseQueryGenerator', {
enumerable: true,
get: function () {
return suspenseQueryGenerator;
}
});
//# sourceMappingURL=generators-BiW_MevM.cjs.map