diff --git a/.changeset/dirty-doors-move.md b/.changeset/dirty-doors-move.md new file mode 100644 index 000000000..8dbcf7d03 --- /dev/null +++ b/.changeset/dirty-doors-move.md @@ -0,0 +1,12 @@ +--- +"@kubb/plugin-svelte-query": minor +"@kubb/plugin-react-query": minor +"@kubb/plugin-solid-query": minor +"@kubb/plugin-vue-query": minor +"@kubb/plugin-client": minor +"@kubb/plugin-faker": minor +"@kubb/plugin-msw": minor +"@kubb/plugin-swr": minor +--- + +Group API clients by path structure diff --git a/docs/changelog.md b/docs/changelog.md index ff5bdffed..9bef1e8d0 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,7 +5,20 @@ title: Changelog # Changelog ## 3.1.0 -- [`plugin-msw`](/plugins/plugin-msw): Support dynamic and customizable data in handlers +- [`plugin-react-query`](/plugins/plugin-react-query/): Group API clients by path structure +- [`plugin-svelte-query`](/plugins/plugin-svelte-query/): Group API clients by path structure +- [`plugin-vue-query`](/plugins/plugin-vue-query/): Group API clients by path structure +- [`plugin-solid-query`](/plugins/plugin-solid-query/): Group API clients by path structure +- [`plugin-msw`](/plugins/plugin-msw): Group API clients by path structure +```typescript +group: { + type: 'path', + name: ({ group }) => { + const firstSegment = group.split('/')[1]; + return firstSegment; + } +} +``` ```typescript findPetsByStatusHandler((info) => { const { params } = info diff --git a/examples/advanced/src/gen/msw/petController/findPetsByStatusHandler.ts b/examples/advanced/src/gen/msw/petController/findPetsByStatusHandler.ts index cfeb727a8..0ab50b461 100644 --- a/examples/advanced/src/gen/msw/petController/findPetsByStatusHandler.ts +++ b/examples/advanced/src/gen/msw/petController/findPetsByStatusHandler.ts @@ -1,5 +1,5 @@ -import { http } from 'msw' import type { FindPetsByStatusQueryResponse } from '../../models/ts/petController/FindPetsByStatus.ts' +import { http } from 'msw' export function findPetsByStatusHandler(data?: FindPetsByStatusQueryResponse | ((info: Parameters[1]>[0]) => Response)) { return http.get('*/pet/findByStatus/:step_id', function handler(info) { diff --git a/examples/client/kubb.config.ts b/examples/client/kubb.config.ts index c2f3cf4b9..0866ecc6f 100644 --- a/examples/client/kubb.config.ts +++ b/examples/client/kubb.config.ts @@ -69,6 +69,12 @@ export default defineConfig(() => { pattern: 'store', }, ], + group: { + type: 'tag', + name({ group }) { + return `${group}Controller` + }, + }, dataReturnType: 'full', pathParamsType: 'object', }), @@ -111,6 +117,12 @@ export default defineConfig(() => { pattern: 'store', }, ], + group: { + type: 'tag', + name({ group }) { + return `${group}Controller` + }, + }, transformers: { name(name, type) { if (type === 'function') { diff --git a/examples/client/src/gen/index.ts b/examples/client/src/gen/index.ts index fa0072804..1ad1f89e8 100644 --- a/examples/client/src/gen/index.ts +++ b/examples/client/src/gen/index.ts @@ -148,5 +148,12 @@ export { addPetRequestStatusEnum } from './models/ts/AddPetRequest.js' export { orderStatusEnum, orderHttpStatusEnum } from './models/ts/Order.js' export { petStatusEnum } from './models/ts/Pet.js' export { findPetsByStatusQueryParamsStatusEnum } from './models/ts/petController/FindPetsByStatus.js' -export { getInventoryController, placeOrderController, placeOrderPatchController, getOrderByIdController, deleteOrderController } from './tag.js' +export { + getInventoryController, + placeOrderController, + placeOrderPatchController, + getOrderByIdController, + deleteOrderController, + storeController, +} from './tag.js' export { getInventory, placeOrder, placeOrderPatch, getOrderById, deleteOrder } from './tagObject.js' diff --git a/examples/client/src/gen/tag.ts b/examples/client/src/gen/tag.ts index a7faf64bb..70fa83994 100644 --- a/examples/client/src/gen/tag.ts +++ b/examples/client/src/gen/tag.ts @@ -64,3 +64,7 @@ export async function deleteOrderController(orderId: DeleteOrderPathParams['orde }) return res.data } + +export function storeController() { + return { getInventoryController, placeOrderController, placeOrderPatchController, getOrderByIdController, deleteOrderController } +} diff --git a/examples/react-query/kubb.config.ts b/examples/react-query/kubb.config.ts index 8db408806..5ea87a81d 100644 --- a/examples/react-query/kubb.config.ts +++ b/examples/react-query/kubb.config.ts @@ -36,6 +36,9 @@ export const config = { output: { path: './hooks', }, + group: { + type: 'path', + }, queryKey(props) { const keys = QueryKey.getTransformer(props) return ['"v5"', ...keys] diff --git a/examples/react-query/src/App.tsx b/examples/react-query/src/App.tsx index 6bce992b2..d0873cb52 100644 --- a/examples/react-query/src/App.tsx +++ b/examples/react-query/src/App.tsx @@ -1,10 +1,13 @@ import { QueryClient, QueryClientProvider, useQueries } from '@tanstack/react-query' import { ReactQueryDevtools } from '@tanstack/react-query-devtools' import { useState } from 'react' -import { findPetsByStatusQueryOptionsHook, useFindPetsByStatusHook } from './gen/hooks/useFindPetsByStatusHook.ts' -import { useFindPetsByTagsInfiniteHook } from './gen/hooks/useFindPetsByTagsInfiniteHook.ts' -import { useUpdatePetWithFormHook } from './gen/hooks/useUpdatePetWithFormHook.ts' -import type { FindPetsByStatusQueryParamsStatusEnum } from './gen/models/FindPetsByStatus.ts' +import { + type FindPetsByStatusQueryParamsStatusEnum, + findPetsByStatusQueryOptionsHook, + useFindPetsByStatusHook, + useFindPetsByTagsInfiniteHook, + useUpdatePetWithFormHook, +} from './gen/index.ts' const queryClient = new QueryClient() diff --git a/examples/react-query/src/gen/hooks/index.ts b/examples/react-query/src/gen/hooks/index.ts index 2d940c575..8d9537715 100644 --- a/examples/react-query/src/gen/hooks/index.ts +++ b/examples/react-query/src/gen/hooks/index.ts @@ -1,68 +1,68 @@ -export type { AddPetMutationKey } from './useAddPetHook.ts' -export type { CreateUserMutationKey } from './useCreateUserHook.ts' -export type { CreateUsersWithListInputMutationKey } from './useCreateUsersWithListInputHook.ts' -export type { DeleteOrderMutationKey } from './useDeleteOrderHook.ts' -export type { DeletePetMutationKey } from './useDeletePetHook.ts' -export type { DeleteUserMutationKey } from './useDeleteUserHook.ts' -export type { FindPetsByStatusQueryKey } from './useFindPetsByStatusHook.ts' -export type { FindPetsByStatusSuspenseQueryKey } from './useFindPetsByStatusSuspenseHook.ts' -export type { FindPetsByTagsQueryKey } from './useFindPetsByTagsHook.ts' -export type { FindPetsByTagsInfiniteQueryKey } from './useFindPetsByTagsInfiniteHook.ts' -export type { FindPetsByTagsSuspenseQueryKey } from './useFindPetsByTagsSuspenseHook.ts' -export type { GetInventoryQueryKey } from './useGetInventoryHook.ts' -export type { GetInventorySuspenseQueryKey } from './useGetInventorySuspenseHook.ts' -export type { GetOrderByIdQueryKey } from './useGetOrderByIdHook.ts' -export type { GetOrderByIdSuspenseQueryKey } from './useGetOrderByIdSuspenseHook.ts' -export type { GetPetByIdQueryKey } from './useGetPetByIdHook.ts' -export type { GetPetByIdSuspenseQueryKey } from './useGetPetByIdSuspenseHook.ts' -export type { GetUserByNameQueryKey } from './useGetUserByNameHook.ts' -export type { GetUserByNameSuspenseQueryKey } from './useGetUserByNameSuspenseHook.ts' -export type { LoginUserQueryKey } from './useLoginUserHook.ts' -export type { LoginUserSuspenseQueryKey } from './useLoginUserSuspenseHook.ts' -export type { LogoutUserQueryKey } from './useLogoutUserHook.ts' -export type { LogoutUserSuspenseQueryKey } from './useLogoutUserSuspenseHook.ts' -export type { PlaceOrderMutationKey } from './usePlaceOrderHook.ts' -export type { PlaceOrderPatchMutationKey } from './usePlaceOrderPatchHook.ts' -export type { UpdatePetMutationKey } from './useUpdatePetHook.ts' -export type { UpdatePetWithFormQueryKey } from './useUpdatePetWithFormHook.ts' -export type { UpdatePetWithFormSuspenseQueryKey } from './useUpdatePetWithFormSuspenseHook.ts' -export type { UpdateUserMutationKey } from './useUpdateUserHook.ts' -export type { UploadFileMutationKey } from './useUploadFileHook.ts' -export { addPetMutationKey, useAddPetHook } from './useAddPetHook.ts' -export { createUserMutationKey, useCreateUserHook } from './useCreateUserHook.ts' -export { createUsersWithListInputMutationKey, useCreateUsersWithListInputHook } from './useCreateUsersWithListInputHook.ts' -export { deleteOrderMutationKey, useDeleteOrderHook } from './useDeleteOrderHook.ts' -export { deletePetMutationKey, useDeletePetHook } from './useDeletePetHook.ts' -export { deleteUserMutationKey, useDeleteUserHook } from './useDeleteUserHook.ts' -export { findPetsByStatusQueryKey, findPetsByStatusQueryOptionsHook, useFindPetsByStatusHook } from './useFindPetsByStatusHook.ts' +export type { AddPetMutationKey } from './pet/useAddPetHook.ts' +export type { DeletePetMutationKey } from './pet/useDeletePetHook.ts' +export type { FindPetsByStatusQueryKey } from './pet/useFindPetsByStatusHook.ts' +export type { FindPetsByStatusSuspenseQueryKey } from './pet/useFindPetsByStatusSuspenseHook.ts' +export type { FindPetsByTagsQueryKey } from './pet/useFindPetsByTagsHook.ts' +export type { FindPetsByTagsInfiniteQueryKey } from './pet/useFindPetsByTagsInfiniteHook.ts' +export type { FindPetsByTagsSuspenseQueryKey } from './pet/useFindPetsByTagsSuspenseHook.ts' +export type { GetPetByIdQueryKey } from './pet/useGetPetByIdHook.ts' +export type { GetPetByIdSuspenseQueryKey } from './pet/useGetPetByIdSuspenseHook.ts' +export type { UpdatePetMutationKey } from './pet/useUpdatePetHook.ts' +export type { UpdatePetWithFormQueryKey } from './pet/useUpdatePetWithFormHook.ts' +export type { UpdatePetWithFormSuspenseQueryKey } from './pet/useUpdatePetWithFormSuspenseHook.ts' +export type { UploadFileMutationKey } from './pet/useUploadFileHook.ts' +export type { DeleteOrderMutationKey } from './store/useDeleteOrderHook.ts' +export type { GetInventoryQueryKey } from './store/useGetInventoryHook.ts' +export type { GetInventorySuspenseQueryKey } from './store/useGetInventorySuspenseHook.ts' +export type { GetOrderByIdQueryKey } from './store/useGetOrderByIdHook.ts' +export type { GetOrderByIdSuspenseQueryKey } from './store/useGetOrderByIdSuspenseHook.ts' +export type { PlaceOrderMutationKey } from './store/usePlaceOrderHook.ts' +export type { PlaceOrderPatchMutationKey } from './store/usePlaceOrderPatchHook.ts' +export type { CreateUserMutationKey } from './user/useCreateUserHook.ts' +export type { CreateUsersWithListInputMutationKey } from './user/useCreateUsersWithListInputHook.ts' +export type { DeleteUserMutationKey } from './user/useDeleteUserHook.ts' +export type { GetUserByNameQueryKey } from './user/useGetUserByNameHook.ts' +export type { GetUserByNameSuspenseQueryKey } from './user/useGetUserByNameSuspenseHook.ts' +export type { LoginUserQueryKey } from './user/useLoginUserHook.ts' +export type { LoginUserSuspenseQueryKey } from './user/useLoginUserSuspenseHook.ts' +export type { LogoutUserQueryKey } from './user/useLogoutUserHook.ts' +export type { LogoutUserSuspenseQueryKey } from './user/useLogoutUserSuspenseHook.ts' +export type { UpdateUserMutationKey } from './user/useUpdateUserHook.ts' +export { addPetMutationKey, useAddPetHook } from './pet/useAddPetHook.ts' +export { deletePetMutationKey, useDeletePetHook } from './pet/useDeletePetHook.ts' +export { findPetsByStatusQueryKey, findPetsByStatusQueryOptionsHook, useFindPetsByStatusHook } from './pet/useFindPetsByStatusHook.ts' export { findPetsByStatusSuspenseQueryKey, findPetsByStatusSuspenseQueryOptionsHook, useFindPetsByStatusSuspenseHook, -} from './useFindPetsByStatusSuspenseHook.ts' -export { findPetsByTagsQueryKey, findPetsByTagsQueryOptionsHook, useFindPetsByTagsHook } from './useFindPetsByTagsHook.ts' -export { findPetsByTagsInfiniteQueryKey, findPetsByTagsInfiniteQueryOptionsHook, useFindPetsByTagsInfiniteHook } from './useFindPetsByTagsInfiniteHook.ts' -export { findPetsByTagsSuspenseQueryKey, findPetsByTagsSuspenseQueryOptionsHook, useFindPetsByTagsSuspenseHook } from './useFindPetsByTagsSuspenseHook.ts' -export { getInventoryQueryKey, getInventoryQueryOptionsHook } from './useGetInventoryHook.ts' -export { getInventorySuspenseQueryKey, getInventorySuspenseQueryOptionsHook, useGetInventorySuspenseHook } from './useGetInventorySuspenseHook.ts' -export { getOrderByIdQueryKey, getOrderByIdQueryOptionsHook, useGetOrderByIdHook } from './useGetOrderByIdHook.ts' -export { getOrderByIdSuspenseQueryKey, getOrderByIdSuspenseQueryOptionsHook, useGetOrderByIdSuspenseHook } from './useGetOrderByIdSuspenseHook.ts' -export { getPetByIdQueryKey, getPetByIdQueryOptionsHook, useGetPetByIdHook } from './useGetPetByIdHook.ts' -export { getPetByIdSuspenseQueryKey, getPetByIdSuspenseQueryOptionsHook, useGetPetByIdSuspenseHook } from './useGetPetByIdSuspenseHook.ts' -export { getUserByNameQueryKey, getUserByNameQueryOptionsHook, useGetUserByNameHook } from './useGetUserByNameHook.ts' -export { getUserByNameSuspenseQueryKey, getUserByNameSuspenseQueryOptionsHook, useGetUserByNameSuspenseHook } from './useGetUserByNameSuspenseHook.ts' -export { loginUserQueryKey, loginUserQueryOptionsHook, useLoginUserHook } from './useLoginUserHook.ts' -export { loginUserSuspenseQueryKey, loginUserSuspenseQueryOptionsHook, useLoginUserSuspenseHook } from './useLoginUserSuspenseHook.ts' -export { logoutUserQueryKey, logoutUserQueryOptionsHook, useLogoutUserHook } from './useLogoutUserHook.ts' -export { logoutUserSuspenseQueryKey, logoutUserSuspenseQueryOptionsHook, useLogoutUserSuspenseHook } from './useLogoutUserSuspenseHook.ts' -export { placeOrderMutationKey, usePlaceOrderHook } from './usePlaceOrderHook.ts' -export { placeOrderPatchMutationKey, usePlaceOrderPatchHook } from './usePlaceOrderPatchHook.ts' -export { updatePetMutationKey, useUpdatePetHook } from './useUpdatePetHook.ts' -export { updatePetWithFormQueryKey, updatePetWithFormQueryOptionsHook, useUpdatePetWithFormHook } from './useUpdatePetWithFormHook.ts' +} from './pet/useFindPetsByStatusSuspenseHook.ts' +export { findPetsByTagsQueryKey, findPetsByTagsQueryOptionsHook, useFindPetsByTagsHook } from './pet/useFindPetsByTagsHook.ts' +export { findPetsByTagsInfiniteQueryKey, findPetsByTagsInfiniteQueryOptionsHook, useFindPetsByTagsInfiniteHook } from './pet/useFindPetsByTagsInfiniteHook.ts' +export { findPetsByTagsSuspenseQueryKey, findPetsByTagsSuspenseQueryOptionsHook, useFindPetsByTagsSuspenseHook } from './pet/useFindPetsByTagsSuspenseHook.ts' +export { getPetByIdQueryKey, getPetByIdQueryOptionsHook, useGetPetByIdHook } from './pet/useGetPetByIdHook.ts' +export { getPetByIdSuspenseQueryKey, getPetByIdSuspenseQueryOptionsHook, useGetPetByIdSuspenseHook } from './pet/useGetPetByIdSuspenseHook.ts' +export { updatePetMutationKey, useUpdatePetHook } from './pet/useUpdatePetHook.ts' +export { updatePetWithFormQueryKey, updatePetWithFormQueryOptionsHook, useUpdatePetWithFormHook } from './pet/useUpdatePetWithFormHook.ts' export { updatePetWithFormSuspenseQueryKey, updatePetWithFormSuspenseQueryOptionsHook, useUpdatePetWithFormSuspenseHook, -} from './useUpdatePetWithFormSuspenseHook.ts' -export { updateUserMutationKey, useUpdateUserHook } from './useUpdateUserHook.ts' -export { uploadFileMutationKey, useUploadFileHook } from './useUploadFileHook.ts' +} from './pet/useUpdatePetWithFormSuspenseHook.ts' +export { uploadFileMutationKey, useUploadFileHook } from './pet/useUploadFileHook.ts' +export { deleteOrderMutationKey, useDeleteOrderHook } from './store/useDeleteOrderHook.ts' +export { getInventoryQueryKey, getInventoryQueryOptionsHook } from './store/useGetInventoryHook.ts' +export { getInventorySuspenseQueryKey, getInventorySuspenseQueryOptionsHook, useGetInventorySuspenseHook } from './store/useGetInventorySuspenseHook.ts' +export { getOrderByIdQueryKey, getOrderByIdQueryOptionsHook, useGetOrderByIdHook } from './store/useGetOrderByIdHook.ts' +export { getOrderByIdSuspenseQueryKey, getOrderByIdSuspenseQueryOptionsHook, useGetOrderByIdSuspenseHook } from './store/useGetOrderByIdSuspenseHook.ts' +export { placeOrderMutationKey, usePlaceOrderHook } from './store/usePlaceOrderHook.ts' +export { placeOrderPatchMutationKey, usePlaceOrderPatchHook } from './store/usePlaceOrderPatchHook.ts' +export { createUserMutationKey, useCreateUserHook } from './user/useCreateUserHook.ts' +export { createUsersWithListInputMutationKey, useCreateUsersWithListInputHook } from './user/useCreateUsersWithListInputHook.ts' +export { deleteUserMutationKey, useDeleteUserHook } from './user/useDeleteUserHook.ts' +export { getUserByNameQueryKey, getUserByNameQueryOptionsHook, useGetUserByNameHook } from './user/useGetUserByNameHook.ts' +export { getUserByNameSuspenseQueryKey, getUserByNameSuspenseQueryOptionsHook, useGetUserByNameSuspenseHook } from './user/useGetUserByNameSuspenseHook.ts' +export { loginUserQueryKey, loginUserQueryOptionsHook, useLoginUserHook } from './user/useLoginUserHook.ts' +export { loginUserSuspenseQueryKey, loginUserSuspenseQueryOptionsHook, useLoginUserSuspenseHook } from './user/useLoginUserSuspenseHook.ts' +export { logoutUserQueryKey, logoutUserQueryOptionsHook, useLogoutUserHook } from './user/useLogoutUserHook.ts' +export { logoutUserSuspenseQueryKey, logoutUserSuspenseQueryOptionsHook, useLogoutUserSuspenseHook } from './user/useLogoutUserSuspenseHook.ts' +export { updateUserMutationKey, useUpdateUserHook } from './user/useUpdateUserHook.ts' diff --git a/examples/react-query/src/gen/hooks/pet/index.ts b/examples/react-query/src/gen/hooks/pet/index.ts new file mode 100644 index 000000000..216f4d5e3 --- /dev/null +++ b/examples/react-query/src/gen/hooks/pet/index.ts @@ -0,0 +1,34 @@ +export type { AddPetMutationKey } from './useAddPetHook.ts' +export type { DeletePetMutationKey } from './useDeletePetHook.ts' +export type { FindPetsByStatusQueryKey } from './useFindPetsByStatusHook.ts' +export type { FindPetsByStatusSuspenseQueryKey } from './useFindPetsByStatusSuspenseHook.ts' +export type { FindPetsByTagsQueryKey } from './useFindPetsByTagsHook.ts' +export type { FindPetsByTagsInfiniteQueryKey } from './useFindPetsByTagsInfiniteHook.ts' +export type { FindPetsByTagsSuspenseQueryKey } from './useFindPetsByTagsSuspenseHook.ts' +export type { GetPetByIdQueryKey } from './useGetPetByIdHook.ts' +export type { GetPetByIdSuspenseQueryKey } from './useGetPetByIdSuspenseHook.ts' +export type { UpdatePetMutationKey } from './useUpdatePetHook.ts' +export type { UpdatePetWithFormQueryKey } from './useUpdatePetWithFormHook.ts' +export type { UpdatePetWithFormSuspenseQueryKey } from './useUpdatePetWithFormSuspenseHook.ts' +export type { UploadFileMutationKey } from './useUploadFileHook.ts' +export { addPetMutationKey, useAddPetHook } from './useAddPetHook.ts' +export { deletePetMutationKey, useDeletePetHook } from './useDeletePetHook.ts' +export { findPetsByStatusQueryKey, findPetsByStatusQueryOptionsHook, useFindPetsByStatusHook } from './useFindPetsByStatusHook.ts' +export { + findPetsByStatusSuspenseQueryKey, + findPetsByStatusSuspenseQueryOptionsHook, + useFindPetsByStatusSuspenseHook, +} from './useFindPetsByStatusSuspenseHook.ts' +export { findPetsByTagsQueryKey, findPetsByTagsQueryOptionsHook, useFindPetsByTagsHook } from './useFindPetsByTagsHook.ts' +export { findPetsByTagsInfiniteQueryKey, findPetsByTagsInfiniteQueryOptionsHook, useFindPetsByTagsInfiniteHook } from './useFindPetsByTagsInfiniteHook.ts' +export { findPetsByTagsSuspenseQueryKey, findPetsByTagsSuspenseQueryOptionsHook, useFindPetsByTagsSuspenseHook } from './useFindPetsByTagsSuspenseHook.ts' +export { getPetByIdQueryKey, getPetByIdQueryOptionsHook, useGetPetByIdHook } from './useGetPetByIdHook.ts' +export { getPetByIdSuspenseQueryKey, getPetByIdSuspenseQueryOptionsHook, useGetPetByIdSuspenseHook } from './useGetPetByIdSuspenseHook.ts' +export { updatePetMutationKey, useUpdatePetHook } from './useUpdatePetHook.ts' +export { updatePetWithFormQueryKey, updatePetWithFormQueryOptionsHook, useUpdatePetWithFormHook } from './useUpdatePetWithFormHook.ts' +export { + updatePetWithFormSuspenseQueryKey, + updatePetWithFormSuspenseQueryOptionsHook, + useUpdatePetWithFormSuspenseHook, +} from './useUpdatePetWithFormSuspenseHook.ts' +export { uploadFileMutationKey, useUploadFileHook } from './useUploadFileHook.ts' diff --git a/examples/react-query/src/gen/hooks/useAddPetHook.ts b/examples/react-query/src/gen/hooks/pet/useAddPetHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useAddPetHook.ts rename to examples/react-query/src/gen/hooks/pet/useAddPetHook.ts index 6afaf8676..29407c1ba 100644 --- a/examples/react-query/src/gen/hooks/useAddPetHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useAddPetHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { AddPetMutationRequest, AddPetMutationResponse, AddPet405 } from '../models/AddPet.ts' +import type { AddPetMutationRequest, AddPetMutationResponse, AddPet405 } from '../../models/AddPet.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useDeletePetHook.ts b/examples/react-query/src/gen/hooks/pet/useDeletePetHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/useDeletePetHook.ts rename to examples/react-query/src/gen/hooks/pet/useDeletePetHook.ts index 7eaca92a4..9eb7cfd30 100644 --- a/examples/react-query/src/gen/hooks/useDeletePetHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useDeletePetHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { DeletePetMutationResponse, DeletePetPathParams, DeletePetHeaderParams, DeletePet400 } from '../models/DeletePet.ts' +import type { DeletePetMutationResponse, DeletePetPathParams, DeletePetHeaderParams, DeletePet400 } from '../../models/DeletePet.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useFindPetsByStatusHook.ts b/examples/react-query/src/gen/hooks/pet/useFindPetsByStatusHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useFindPetsByStatusHook.ts rename to examples/react-query/src/gen/hooks/pet/useFindPetsByStatusHook.ts index ece98e854..732f7ffd8 100644 --- a/examples/react-query/src/gen/hooks/useFindPetsByStatusHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useFindPetsByStatusHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams, FindPetsByStatus400 } from '../models/FindPetsByStatus.ts' +import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams, FindPetsByStatus400 } from '../../models/FindPetsByStatus.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query' import { queryOptions, useQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useFindPetsByStatusSuspenseHook.ts b/examples/react-query/src/gen/hooks/pet/useFindPetsByStatusSuspenseHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useFindPetsByStatusSuspenseHook.ts rename to examples/react-query/src/gen/hooks/pet/useFindPetsByStatusSuspenseHook.ts index 5dc63270b..1f02ca60d 100644 --- a/examples/react-query/src/gen/hooks/useFindPetsByStatusSuspenseHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useFindPetsByStatusSuspenseHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams, FindPetsByStatus400 } from '../models/FindPetsByStatus.ts' +import type { FindPetsByStatusQueryResponse, FindPetsByStatusQueryParams, FindPetsByStatus400 } from '../../models/FindPetsByStatus.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useFindPetsByTagsHook.ts b/examples/react-query/src/gen/hooks/pet/useFindPetsByTagsHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useFindPetsByTagsHook.ts rename to examples/react-query/src/gen/hooks/pet/useFindPetsByTagsHook.ts index 3aed0309e..71f50c2d5 100644 --- a/examples/react-query/src/gen/hooks/useFindPetsByTagsHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useFindPetsByTagsHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, FindPetsByTags400 } from '../models/FindPetsByTags.ts' +import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, FindPetsByTags400 } from '../../models/FindPetsByTags.ts' import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/client' import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query' import { queryOptions, useQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useFindPetsByTagsInfiniteHook.ts b/examples/react-query/src/gen/hooks/pet/useFindPetsByTagsInfiniteHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useFindPetsByTagsInfiniteHook.ts rename to examples/react-query/src/gen/hooks/pet/useFindPetsByTagsInfiniteHook.ts index 053e5b536..67d63c5fd 100644 --- a/examples/react-query/src/gen/hooks/useFindPetsByTagsInfiniteHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useFindPetsByTagsInfiniteHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, FindPetsByTags400 } from '../models/FindPetsByTags.ts' +import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, FindPetsByTags400 } from '../../models/FindPetsByTags.ts' import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/client' import type { InfiniteData, QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from '@tanstack/react-query' import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useFindPetsByTagsSuspenseHook.ts b/examples/react-query/src/gen/hooks/pet/useFindPetsByTagsSuspenseHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useFindPetsByTagsSuspenseHook.ts rename to examples/react-query/src/gen/hooks/pet/useFindPetsByTagsSuspenseHook.ts index 6c0606ab0..917abc9fa 100644 --- a/examples/react-query/src/gen/hooks/useFindPetsByTagsSuspenseHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useFindPetsByTagsSuspenseHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, FindPetsByTags400 } from '../models/FindPetsByTags.ts' +import type { FindPetsByTagsQueryResponse, FindPetsByTagsQueryParams, FindPetsByTags400 } from '../../models/FindPetsByTags.ts' import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/client' import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useGetPetByIdHook.ts b/examples/react-query/src/gen/hooks/pet/useGetPetByIdHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useGetPetByIdHook.ts rename to examples/react-query/src/gen/hooks/pet/useGetPetByIdHook.ts index bfc34bc56..d485796b3 100644 --- a/examples/react-query/src/gen/hooks/useGetPetByIdHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useGetPetByIdHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { GetPetByIdQueryResponse, GetPetByIdPathParams, GetPetById400, GetPetById404 } from '../models/GetPetById.ts' +import type { GetPetByIdQueryResponse, GetPetByIdPathParams, GetPetById400, GetPetById404 } from '../../models/GetPetById.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query' import { queryOptions, useQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useGetPetByIdSuspenseHook.ts b/examples/react-query/src/gen/hooks/pet/useGetPetByIdSuspenseHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useGetPetByIdSuspenseHook.ts rename to examples/react-query/src/gen/hooks/pet/useGetPetByIdSuspenseHook.ts index 0ab994ff2..2459f6183 100644 --- a/examples/react-query/src/gen/hooks/useGetPetByIdSuspenseHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useGetPetByIdSuspenseHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { GetPetByIdQueryResponse, GetPetByIdPathParams, GetPetById400, GetPetById404 } from '../models/GetPetById.ts' +import type { GetPetByIdQueryResponse, GetPetByIdPathParams, GetPetById400, GetPetById404 } from '../../models/GetPetById.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useUpdatePetHook.ts b/examples/react-query/src/gen/hooks/pet/useUpdatePetHook.ts similarity index 95% rename from examples/react-query/src/gen/hooks/useUpdatePetHook.ts rename to examples/react-query/src/gen/hooks/pet/useUpdatePetHook.ts index 426cf0945..949dff978 100644 --- a/examples/react-query/src/gen/hooks/useUpdatePetHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useUpdatePetHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { UpdatePetMutationRequest, UpdatePetMutationResponse, UpdatePet400, UpdatePet404, UpdatePet405 } from '../models/UpdatePet.ts' +import type { UpdatePetMutationRequest, UpdatePetMutationResponse, UpdatePet400, UpdatePet404, UpdatePet405 } from '../../models/UpdatePet.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts b/examples/react-query/src/gen/hooks/pet/useUpdatePetWithFormHook.ts similarity index 98% rename from examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts rename to examples/react-query/src/gen/hooks/pet/useUpdatePetWithFormHook.ts index 1e8ddc92b..bd1ff8067 100644 --- a/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useUpdatePetWithFormHook.ts @@ -4,7 +4,7 @@ import type { UpdatePetWithFormPathParams, UpdatePetWithFormQueryParams, UpdatePetWithForm405, -} from '../models/UpdatePetWithForm.ts' +} from '../../models/UpdatePetWithForm.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query' import { queryOptions, useQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useUpdatePetWithFormSuspenseHook.ts b/examples/react-query/src/gen/hooks/pet/useUpdatePetWithFormSuspenseHook.ts similarity index 98% rename from examples/react-query/src/gen/hooks/useUpdatePetWithFormSuspenseHook.ts rename to examples/react-query/src/gen/hooks/pet/useUpdatePetWithFormSuspenseHook.ts index 6344d2ff5..160e7c781 100644 --- a/examples/react-query/src/gen/hooks/useUpdatePetWithFormSuspenseHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useUpdatePetWithFormSuspenseHook.ts @@ -4,7 +4,7 @@ import type { UpdatePetWithFormPathParams, UpdatePetWithFormQueryParams, UpdatePetWithForm405, -} from '../models/UpdatePetWithForm.ts' +} from '../../models/UpdatePetWithForm.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useUploadFileHook.ts b/examples/react-query/src/gen/hooks/pet/useUploadFileHook.ts similarity index 95% rename from examples/react-query/src/gen/hooks/useUploadFileHook.ts rename to examples/react-query/src/gen/hooks/pet/useUploadFileHook.ts index 4dd33fa34..8fbb5dce7 100644 --- a/examples/react-query/src/gen/hooks/useUploadFileHook.ts +++ b/examples/react-query/src/gen/hooks/pet/useUploadFileHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { UploadFileMutationRequest, UploadFileMutationResponse, UploadFilePathParams, UploadFileQueryParams } from '../models/UploadFile.ts' +import type { UploadFileMutationRequest, UploadFileMutationResponse, UploadFilePathParams, UploadFileQueryParams } from '../../models/UploadFile.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/store/index.ts b/examples/react-query/src/gen/hooks/store/index.ts new file mode 100644 index 000000000..2856659e6 --- /dev/null +++ b/examples/react-query/src/gen/hooks/store/index.ts @@ -0,0 +1,14 @@ +export type { DeleteOrderMutationKey } from './useDeleteOrderHook.ts' +export type { GetInventoryQueryKey } from './useGetInventoryHook.ts' +export type { GetInventorySuspenseQueryKey } from './useGetInventorySuspenseHook.ts' +export type { GetOrderByIdQueryKey } from './useGetOrderByIdHook.ts' +export type { GetOrderByIdSuspenseQueryKey } from './useGetOrderByIdSuspenseHook.ts' +export type { PlaceOrderMutationKey } from './usePlaceOrderHook.ts' +export type { PlaceOrderPatchMutationKey } from './usePlaceOrderPatchHook.ts' +export { deleteOrderMutationKey, useDeleteOrderHook } from './useDeleteOrderHook.ts' +export { getInventoryQueryKey, getInventoryQueryOptionsHook } from './useGetInventoryHook.ts' +export { getInventorySuspenseQueryKey, getInventorySuspenseQueryOptionsHook, useGetInventorySuspenseHook } from './useGetInventorySuspenseHook.ts' +export { getOrderByIdQueryKey, getOrderByIdQueryOptionsHook, useGetOrderByIdHook } from './useGetOrderByIdHook.ts' +export { getOrderByIdSuspenseQueryKey, getOrderByIdSuspenseQueryOptionsHook, useGetOrderByIdSuspenseHook } from './useGetOrderByIdSuspenseHook.ts' +export { placeOrderMutationKey, usePlaceOrderHook } from './usePlaceOrderHook.ts' +export { placeOrderPatchMutationKey, usePlaceOrderPatchHook } from './usePlaceOrderPatchHook.ts' diff --git a/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts b/examples/react-query/src/gen/hooks/store/useDeleteOrderHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/useDeleteOrderHook.ts rename to examples/react-query/src/gen/hooks/store/useDeleteOrderHook.ts index a3e88d7dd..0469eb661 100644 --- a/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts +++ b/examples/react-query/src/gen/hooks/store/useDeleteOrderHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { DeleteOrderMutationResponse, DeleteOrderPathParams, DeleteOrder400, DeleteOrder404 } from '../models/DeleteOrder.ts' +import type { DeleteOrderMutationResponse, DeleteOrderPathParams, DeleteOrder400, DeleteOrder404 } from '../../models/DeleteOrder.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useGetInventoryHook.ts b/examples/react-query/src/gen/hooks/store/useGetInventoryHook.ts similarity index 92% rename from examples/react-query/src/gen/hooks/useGetInventoryHook.ts rename to examples/react-query/src/gen/hooks/store/useGetInventoryHook.ts index 886fccb95..be32156ca 100644 --- a/examples/react-query/src/gen/hooks/useGetInventoryHook.ts +++ b/examples/react-query/src/gen/hooks/store/useGetInventoryHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { GetInventoryQueryResponse } from '../models/GetInventory.ts' +import type { GetInventoryQueryResponse } from '../../models/GetInventory.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import { queryOptions } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useGetInventorySuspenseHook.ts b/examples/react-query/src/gen/hooks/store/useGetInventorySuspenseHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/useGetInventorySuspenseHook.ts rename to examples/react-query/src/gen/hooks/store/useGetInventorySuspenseHook.ts index d895c4cbd..275ccb979 100644 --- a/examples/react-query/src/gen/hooks/useGetInventorySuspenseHook.ts +++ b/examples/react-query/src/gen/hooks/store/useGetInventorySuspenseHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { GetInventoryQueryResponse } from '../models/GetInventory.ts' +import type { GetInventoryQueryResponse } from '../../models/GetInventory.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useGetOrderByIdHook.ts b/examples/react-query/src/gen/hooks/store/useGetOrderByIdHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useGetOrderByIdHook.ts rename to examples/react-query/src/gen/hooks/store/useGetOrderByIdHook.ts index fc6080a8a..c7080ac75 100644 --- a/examples/react-query/src/gen/hooks/useGetOrderByIdHook.ts +++ b/examples/react-query/src/gen/hooks/store/useGetOrderByIdHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { GetOrderByIdQueryResponse, GetOrderByIdPathParams, GetOrderById400, GetOrderById404 } from '../models/GetOrderById.ts' +import type { GetOrderByIdQueryResponse, GetOrderByIdPathParams, GetOrderById400, GetOrderById404 } from '../../models/GetOrderById.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query' import { queryOptions, useQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useGetOrderByIdSuspenseHook.ts b/examples/react-query/src/gen/hooks/store/useGetOrderByIdSuspenseHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useGetOrderByIdSuspenseHook.ts rename to examples/react-query/src/gen/hooks/store/useGetOrderByIdSuspenseHook.ts index 07646ee48..243465957 100644 --- a/examples/react-query/src/gen/hooks/useGetOrderByIdSuspenseHook.ts +++ b/examples/react-query/src/gen/hooks/store/useGetOrderByIdSuspenseHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { GetOrderByIdQueryResponse, GetOrderByIdPathParams, GetOrderById400, GetOrderById404 } from '../models/GetOrderById.ts' +import type { GetOrderByIdQueryResponse, GetOrderByIdPathParams, GetOrderById400, GetOrderById404 } from '../../models/GetOrderById.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts b/examples/react-query/src/gen/hooks/store/usePlaceOrderHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/usePlaceOrderHook.ts rename to examples/react-query/src/gen/hooks/store/usePlaceOrderHook.ts index fe5fcc0da..cd58a2434 100644 --- a/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts +++ b/examples/react-query/src/gen/hooks/store/usePlaceOrderHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { PlaceOrderMutationRequest, PlaceOrderMutationResponse, PlaceOrder405 } from '../models/PlaceOrder.ts' +import type { PlaceOrderMutationRequest, PlaceOrderMutationResponse, PlaceOrder405 } from '../../models/PlaceOrder.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts b/examples/react-query/src/gen/hooks/store/usePlaceOrderPatchHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts rename to examples/react-query/src/gen/hooks/store/usePlaceOrderPatchHook.ts index 945bab0a9..b28f96123 100644 --- a/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts +++ b/examples/react-query/src/gen/hooks/store/usePlaceOrderPatchHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { PlaceOrderPatchMutationRequest, PlaceOrderPatchMutationResponse, PlaceOrderPatch405 } from '../models/PlaceOrderPatch.ts' +import type { PlaceOrderPatchMutationRequest, PlaceOrderPatchMutationResponse, PlaceOrderPatch405 } from '../../models/PlaceOrderPatch.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/user/index.ts b/examples/react-query/src/gen/hooks/user/index.ts new file mode 100644 index 000000000..6988fc7a3 --- /dev/null +++ b/examples/react-query/src/gen/hooks/user/index.ts @@ -0,0 +1,20 @@ +export type { CreateUserMutationKey } from './useCreateUserHook.ts' +export type { CreateUsersWithListInputMutationKey } from './useCreateUsersWithListInputHook.ts' +export type { DeleteUserMutationKey } from './useDeleteUserHook.ts' +export type { GetUserByNameQueryKey } from './useGetUserByNameHook.ts' +export type { GetUserByNameSuspenseQueryKey } from './useGetUserByNameSuspenseHook.ts' +export type { LoginUserQueryKey } from './useLoginUserHook.ts' +export type { LoginUserSuspenseQueryKey } from './useLoginUserSuspenseHook.ts' +export type { LogoutUserQueryKey } from './useLogoutUserHook.ts' +export type { LogoutUserSuspenseQueryKey } from './useLogoutUserSuspenseHook.ts' +export type { UpdateUserMutationKey } from './useUpdateUserHook.ts' +export { createUserMutationKey, useCreateUserHook } from './useCreateUserHook.ts' +export { createUsersWithListInputMutationKey, useCreateUsersWithListInputHook } from './useCreateUsersWithListInputHook.ts' +export { deleteUserMutationKey, useDeleteUserHook } from './useDeleteUserHook.ts' +export { getUserByNameQueryKey, getUserByNameQueryOptionsHook, useGetUserByNameHook } from './useGetUserByNameHook.ts' +export { getUserByNameSuspenseQueryKey, getUserByNameSuspenseQueryOptionsHook, useGetUserByNameSuspenseHook } from './useGetUserByNameSuspenseHook.ts' +export { loginUserQueryKey, loginUserQueryOptionsHook, useLoginUserHook } from './useLoginUserHook.ts' +export { loginUserSuspenseQueryKey, loginUserSuspenseQueryOptionsHook, useLoginUserSuspenseHook } from './useLoginUserSuspenseHook.ts' +export { logoutUserQueryKey, logoutUserQueryOptionsHook, useLogoutUserHook } from './useLogoutUserHook.ts' +export { logoutUserSuspenseQueryKey, logoutUserSuspenseQueryOptionsHook, useLogoutUserSuspenseHook } from './useLogoutUserSuspenseHook.ts' +export { updateUserMutationKey, useUpdateUserHook } from './useUpdateUserHook.ts' diff --git a/examples/react-query/src/gen/hooks/useCreateUserHook.ts b/examples/react-query/src/gen/hooks/user/useCreateUserHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useCreateUserHook.ts rename to examples/react-query/src/gen/hooks/user/useCreateUserHook.ts index df32017d2..5bb722338 100644 --- a/examples/react-query/src/gen/hooks/useCreateUserHook.ts +++ b/examples/react-query/src/gen/hooks/user/useCreateUserHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { CreateUserMutationRequest, CreateUserMutationResponse } from '../models/CreateUser.ts' +import type { CreateUserMutationRequest, CreateUserMutationResponse } from '../../models/CreateUser.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts b/examples/react-query/src/gen/hooks/user/useCreateUsersWithListInputHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts rename to examples/react-query/src/gen/hooks/user/useCreateUsersWithListInputHook.ts index 615b92293..8fb9abfc3 100644 --- a/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts +++ b/examples/react-query/src/gen/hooks/user/useCreateUsersWithListInputHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { CreateUsersWithListInputMutationRequest, CreateUsersWithListInputMutationResponse } from '../models/CreateUsersWithListInput.ts' +import type { CreateUsersWithListInputMutationRequest, CreateUsersWithListInputMutationResponse } from '../../models/CreateUsersWithListInput.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useDeleteUserHook.ts b/examples/react-query/src/gen/hooks/user/useDeleteUserHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/useDeleteUserHook.ts rename to examples/react-query/src/gen/hooks/user/useDeleteUserHook.ts index fd6b29af0..8ed31002d 100644 --- a/examples/react-query/src/gen/hooks/useDeleteUserHook.ts +++ b/examples/react-query/src/gen/hooks/user/useDeleteUserHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { DeleteUserMutationResponse, DeleteUserPathParams, DeleteUser400, DeleteUser404 } from '../models/DeleteUser.ts' +import type { DeleteUserMutationResponse, DeleteUserPathParams, DeleteUser400, DeleteUser404 } from '../../models/DeleteUser.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useGetUserByNameHook.ts b/examples/react-query/src/gen/hooks/user/useGetUserByNameHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/useGetUserByNameHook.ts rename to examples/react-query/src/gen/hooks/user/useGetUserByNameHook.ts index 2124745d3..c44afdff5 100644 --- a/examples/react-query/src/gen/hooks/useGetUserByNameHook.ts +++ b/examples/react-query/src/gen/hooks/user/useGetUserByNameHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { GetUserByNameQueryResponse, GetUserByNamePathParams, GetUserByName400, GetUserByName404 } from '../models/GetUserByName.ts' +import type { GetUserByNameQueryResponse, GetUserByNamePathParams, GetUserByName400, GetUserByName404 } from '../../models/GetUserByName.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query' import { queryOptions, useQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useGetUserByNameSuspenseHook.ts b/examples/react-query/src/gen/hooks/user/useGetUserByNameSuspenseHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useGetUserByNameSuspenseHook.ts rename to examples/react-query/src/gen/hooks/user/useGetUserByNameSuspenseHook.ts index 439cc3bb4..9fb561079 100644 --- a/examples/react-query/src/gen/hooks/useGetUserByNameSuspenseHook.ts +++ b/examples/react-query/src/gen/hooks/user/useGetUserByNameSuspenseHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { GetUserByNameQueryResponse, GetUserByNamePathParams, GetUserByName400, GetUserByName404 } from '../models/GetUserByName.ts' +import type { GetUserByNameQueryResponse, GetUserByNamePathParams, GetUserByName400, GetUserByName404 } from '../../models/GetUserByName.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useLoginUserHook.ts b/examples/react-query/src/gen/hooks/user/useLoginUserHook.ts similarity index 97% rename from examples/react-query/src/gen/hooks/useLoginUserHook.ts rename to examples/react-query/src/gen/hooks/user/useLoginUserHook.ts index e567768dc..392424142 100644 --- a/examples/react-query/src/gen/hooks/useLoginUserHook.ts +++ b/examples/react-query/src/gen/hooks/user/useLoginUserHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { LoginUserQueryResponse, LoginUserQueryParams, LoginUser400 } from '../models/LoginUser.ts' +import type { LoginUserQueryResponse, LoginUserQueryParams, LoginUser400 } from '../../models/LoginUser.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query' import { queryOptions, useQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useLoginUserSuspenseHook.ts b/examples/react-query/src/gen/hooks/user/useLoginUserSuspenseHook.ts similarity index 98% rename from examples/react-query/src/gen/hooks/useLoginUserSuspenseHook.ts rename to examples/react-query/src/gen/hooks/user/useLoginUserSuspenseHook.ts index 71b76a67f..ce9a46528 100644 --- a/examples/react-query/src/gen/hooks/useLoginUserSuspenseHook.ts +++ b/examples/react-query/src/gen/hooks/user/useLoginUserSuspenseHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { LoginUserQueryResponse, LoginUserQueryParams, LoginUser400 } from '../models/LoginUser.ts' +import type { LoginUserQueryResponse, LoginUserQueryParams, LoginUser400 } from '../../models/LoginUser.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useLogoutUserHook.ts b/examples/react-query/src/gen/hooks/user/useLogoutUserHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/useLogoutUserHook.ts rename to examples/react-query/src/gen/hooks/user/useLogoutUserHook.ts index 6c1206c86..879101dc3 100644 --- a/examples/react-query/src/gen/hooks/useLogoutUserHook.ts +++ b/examples/react-query/src/gen/hooks/user/useLogoutUserHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { LogoutUserQueryResponse } from '../models/LogoutUser.ts' +import type { LogoutUserQueryResponse } from '../../models/LogoutUser.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query' import { queryOptions, useQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useLogoutUserSuspenseHook.ts b/examples/react-query/src/gen/hooks/user/useLogoutUserSuspenseHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/useLogoutUserSuspenseHook.ts rename to examples/react-query/src/gen/hooks/user/useLogoutUserSuspenseHook.ts index 0264b7945..13baebdc5 100644 --- a/examples/react-query/src/gen/hooks/useLogoutUserSuspenseHook.ts +++ b/examples/react-query/src/gen/hooks/user/useLogoutUserSuspenseHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { LogoutUserQueryResponse } from '../models/LogoutUser.ts' +import type { LogoutUserQueryResponse } from '../../models/LogoutUser.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { QueryKey, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query' import { queryOptions, useSuspenseQuery } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/hooks/useUpdateUserHook.ts b/examples/react-query/src/gen/hooks/user/useUpdateUserHook.ts similarity index 96% rename from examples/react-query/src/gen/hooks/useUpdateUserHook.ts rename to examples/react-query/src/gen/hooks/user/useUpdateUserHook.ts index fe4819fbf..32b20b0d5 100644 --- a/examples/react-query/src/gen/hooks/useUpdateUserHook.ts +++ b/examples/react-query/src/gen/hooks/user/useUpdateUserHook.ts @@ -1,5 +1,5 @@ import client from '@kubb/plugin-client/client' -import type { UpdateUserMutationRequest, UpdateUserMutationResponse, UpdateUserPathParams } from '../models/UpdateUser.ts' +import type { UpdateUserMutationRequest, UpdateUserMutationResponse, UpdateUserPathParams } from '../../models/UpdateUser.ts' import type { RequestConfig } from '@kubb/plugin-client/client' import type { UseMutationOptions } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query' diff --git a/examples/react-query/src/gen/index.ts b/examples/react-query/src/gen/index.ts index 278a11ff8..17f6a3417 100644 --- a/examples/react-query/src/gen/index.ts +++ b/examples/react-query/src/gen/index.ts @@ -1,33 +1,33 @@ -export type { AddPetMutationKey } from './hooks/useAddPetHook.ts' -export type { CreateUserMutationKey } from './hooks/useCreateUserHook.ts' -export type { CreateUsersWithListInputMutationKey } from './hooks/useCreateUsersWithListInputHook.ts' -export type { DeleteOrderMutationKey } from './hooks/useDeleteOrderHook.ts' -export type { DeletePetMutationKey } from './hooks/useDeletePetHook.ts' -export type { DeleteUserMutationKey } from './hooks/useDeleteUserHook.ts' -export type { FindPetsByStatusQueryKey } from './hooks/useFindPetsByStatusHook.ts' -export type { FindPetsByStatusSuspenseQueryKey } from './hooks/useFindPetsByStatusSuspenseHook.ts' -export type { FindPetsByTagsQueryKey } from './hooks/useFindPetsByTagsHook.ts' -export type { FindPetsByTagsInfiniteQueryKey } from './hooks/useFindPetsByTagsInfiniteHook.ts' -export type { FindPetsByTagsSuspenseQueryKey } from './hooks/useFindPetsByTagsSuspenseHook.ts' -export type { GetInventoryQueryKey } from './hooks/useGetInventoryHook.ts' -export type { GetInventorySuspenseQueryKey } from './hooks/useGetInventorySuspenseHook.ts' -export type { GetOrderByIdQueryKey } from './hooks/useGetOrderByIdHook.ts' -export type { GetOrderByIdSuspenseQueryKey } from './hooks/useGetOrderByIdSuspenseHook.ts' -export type { GetPetByIdQueryKey } from './hooks/useGetPetByIdHook.ts' -export type { GetPetByIdSuspenseQueryKey } from './hooks/useGetPetByIdSuspenseHook.ts' -export type { GetUserByNameQueryKey } from './hooks/useGetUserByNameHook.ts' -export type { GetUserByNameSuspenseQueryKey } from './hooks/useGetUserByNameSuspenseHook.ts' -export type { LoginUserQueryKey } from './hooks/useLoginUserHook.ts' -export type { LoginUserSuspenseQueryKey } from './hooks/useLoginUserSuspenseHook.ts' -export type { LogoutUserQueryKey } from './hooks/useLogoutUserHook.ts' -export type { LogoutUserSuspenseQueryKey } from './hooks/useLogoutUserSuspenseHook.ts' -export type { PlaceOrderMutationKey } from './hooks/usePlaceOrderHook.ts' -export type { PlaceOrderPatchMutationKey } from './hooks/usePlaceOrderPatchHook.ts' -export type { UpdatePetMutationKey } from './hooks/useUpdatePetHook.ts' -export type { UpdatePetWithFormQueryKey } from './hooks/useUpdatePetWithFormHook.ts' -export type { UpdatePetWithFormSuspenseQueryKey } from './hooks/useUpdatePetWithFormSuspenseHook.ts' -export type { UpdateUserMutationKey } from './hooks/useUpdateUserHook.ts' -export type { UploadFileMutationKey } from './hooks/useUploadFileHook.ts' +export type { AddPetMutationKey } from './hooks/pet/useAddPetHook.ts' +export type { DeletePetMutationKey } from './hooks/pet/useDeletePetHook.ts' +export type { FindPetsByStatusQueryKey } from './hooks/pet/useFindPetsByStatusHook.ts' +export type { FindPetsByStatusSuspenseQueryKey } from './hooks/pet/useFindPetsByStatusSuspenseHook.ts' +export type { FindPetsByTagsQueryKey } from './hooks/pet/useFindPetsByTagsHook.ts' +export type { FindPetsByTagsInfiniteQueryKey } from './hooks/pet/useFindPetsByTagsInfiniteHook.ts' +export type { FindPetsByTagsSuspenseQueryKey } from './hooks/pet/useFindPetsByTagsSuspenseHook.ts' +export type { GetPetByIdQueryKey } from './hooks/pet/useGetPetByIdHook.ts' +export type { GetPetByIdSuspenseQueryKey } from './hooks/pet/useGetPetByIdSuspenseHook.ts' +export type { UpdatePetMutationKey } from './hooks/pet/useUpdatePetHook.ts' +export type { UpdatePetWithFormQueryKey } from './hooks/pet/useUpdatePetWithFormHook.ts' +export type { UpdatePetWithFormSuspenseQueryKey } from './hooks/pet/useUpdatePetWithFormSuspenseHook.ts' +export type { UploadFileMutationKey } from './hooks/pet/useUploadFileHook.ts' +export type { DeleteOrderMutationKey } from './hooks/store/useDeleteOrderHook.ts' +export type { GetInventoryQueryKey } from './hooks/store/useGetInventoryHook.ts' +export type { GetInventorySuspenseQueryKey } from './hooks/store/useGetInventorySuspenseHook.ts' +export type { GetOrderByIdQueryKey } from './hooks/store/useGetOrderByIdHook.ts' +export type { GetOrderByIdSuspenseQueryKey } from './hooks/store/useGetOrderByIdSuspenseHook.ts' +export type { PlaceOrderMutationKey } from './hooks/store/usePlaceOrderHook.ts' +export type { PlaceOrderPatchMutationKey } from './hooks/store/usePlaceOrderPatchHook.ts' +export type { CreateUserMutationKey } from './hooks/user/useCreateUserHook.ts' +export type { CreateUsersWithListInputMutationKey } from './hooks/user/useCreateUsersWithListInputHook.ts' +export type { DeleteUserMutationKey } from './hooks/user/useDeleteUserHook.ts' +export type { GetUserByNameQueryKey } from './hooks/user/useGetUserByNameHook.ts' +export type { GetUserByNameSuspenseQueryKey } from './hooks/user/useGetUserByNameSuspenseHook.ts' +export type { LoginUserQueryKey } from './hooks/user/useLoginUserHook.ts' +export type { LoginUserSuspenseQueryKey } from './hooks/user/useLoginUserSuspenseHook.ts' +export type { LogoutUserQueryKey } from './hooks/user/useLogoutUserHook.ts' +export type { LogoutUserSuspenseQueryKey } from './hooks/user/useLogoutUserSuspenseHook.ts' +export type { UpdateUserMutationKey } from './hooks/user/useUpdateUserHook.ts' export type { AddPet200, AddPet405, AddPetMutationRequest, AddPetMutationResponse, AddPetMutation } from './models/AddPet.ts' export type { AddPetRequestStatusEnum, AddPetRequest } from './models/AddPetRequest.ts' export type { Address } from './models/Address.ts' @@ -119,44 +119,56 @@ export type { } from './models/UploadFile.ts' export type { User } from './models/User.ts' export type { UserArray } from './models/UserArray.ts' -export { addPetMutationKey, useAddPetHook } from './hooks/useAddPetHook.ts' -export { createUserMutationKey, useCreateUserHook } from './hooks/useCreateUserHook.ts' -export { createUsersWithListInputMutationKey, useCreateUsersWithListInputHook } from './hooks/useCreateUsersWithListInputHook.ts' -export { deleteOrderMutationKey, useDeleteOrderHook } from './hooks/useDeleteOrderHook.ts' -export { deletePetMutationKey, useDeletePetHook } from './hooks/useDeletePetHook.ts' -export { deleteUserMutationKey, useDeleteUserHook } from './hooks/useDeleteUserHook.ts' -export { findPetsByStatusQueryKey, findPetsByStatusQueryOptionsHook, useFindPetsByStatusHook } from './hooks/useFindPetsByStatusHook.ts' +export { addPetMutationKey, useAddPetHook } from './hooks/pet/useAddPetHook.ts' +export { deletePetMutationKey, useDeletePetHook } from './hooks/pet/useDeletePetHook.ts' +export { findPetsByStatusQueryKey, findPetsByStatusQueryOptionsHook, useFindPetsByStatusHook } from './hooks/pet/useFindPetsByStatusHook.ts' export { findPetsByStatusSuspenseQueryKey, findPetsByStatusSuspenseQueryOptionsHook, useFindPetsByStatusSuspenseHook, -} from './hooks/useFindPetsByStatusSuspenseHook.ts' -export { findPetsByTagsQueryKey, findPetsByTagsQueryOptionsHook, useFindPetsByTagsHook } from './hooks/useFindPetsByTagsHook.ts' -export { findPetsByTagsInfiniteQueryKey, findPetsByTagsInfiniteQueryOptionsHook, useFindPetsByTagsInfiniteHook } from './hooks/useFindPetsByTagsInfiniteHook.ts' -export { findPetsByTagsSuspenseQueryKey, findPetsByTagsSuspenseQueryOptionsHook, useFindPetsByTagsSuspenseHook } from './hooks/useFindPetsByTagsSuspenseHook.ts' -export { getInventoryQueryKey, getInventoryQueryOptionsHook } from './hooks/useGetInventoryHook.ts' -export { getInventorySuspenseQueryKey, getInventorySuspenseQueryOptionsHook, useGetInventorySuspenseHook } from './hooks/useGetInventorySuspenseHook.ts' -export { getOrderByIdQueryKey, getOrderByIdQueryOptionsHook, useGetOrderByIdHook } from './hooks/useGetOrderByIdHook.ts' -export { getOrderByIdSuspenseQueryKey, getOrderByIdSuspenseQueryOptionsHook, useGetOrderByIdSuspenseHook } from './hooks/useGetOrderByIdSuspenseHook.ts' -export { getPetByIdQueryKey, getPetByIdQueryOptionsHook, useGetPetByIdHook } from './hooks/useGetPetByIdHook.ts' -export { getPetByIdSuspenseQueryKey, getPetByIdSuspenseQueryOptionsHook, useGetPetByIdSuspenseHook } from './hooks/useGetPetByIdSuspenseHook.ts' -export { getUserByNameQueryKey, getUserByNameQueryOptionsHook, useGetUserByNameHook } from './hooks/useGetUserByNameHook.ts' -export { getUserByNameSuspenseQueryKey, getUserByNameSuspenseQueryOptionsHook, useGetUserByNameSuspenseHook } from './hooks/useGetUserByNameSuspenseHook.ts' -export { loginUserQueryKey, loginUserQueryOptionsHook, useLoginUserHook } from './hooks/useLoginUserHook.ts' -export { loginUserSuspenseQueryKey, loginUserSuspenseQueryOptionsHook, useLoginUserSuspenseHook } from './hooks/useLoginUserSuspenseHook.ts' -export { logoutUserQueryKey, logoutUserQueryOptionsHook, useLogoutUserHook } from './hooks/useLogoutUserHook.ts' -export { logoutUserSuspenseQueryKey, logoutUserSuspenseQueryOptionsHook, useLogoutUserSuspenseHook } from './hooks/useLogoutUserSuspenseHook.ts' -export { placeOrderMutationKey, usePlaceOrderHook } from './hooks/usePlaceOrderHook.ts' -export { placeOrderPatchMutationKey, usePlaceOrderPatchHook } from './hooks/usePlaceOrderPatchHook.ts' -export { updatePetMutationKey, useUpdatePetHook } from './hooks/useUpdatePetHook.ts' -export { updatePetWithFormQueryKey, updatePetWithFormQueryOptionsHook, useUpdatePetWithFormHook } from './hooks/useUpdatePetWithFormHook.ts' +} from './hooks/pet/useFindPetsByStatusSuspenseHook.ts' +export { findPetsByTagsQueryKey, findPetsByTagsQueryOptionsHook, useFindPetsByTagsHook } from './hooks/pet/useFindPetsByTagsHook.ts' +export { + findPetsByTagsInfiniteQueryKey, + findPetsByTagsInfiniteQueryOptionsHook, + useFindPetsByTagsInfiniteHook, +} from './hooks/pet/useFindPetsByTagsInfiniteHook.ts' +export { + findPetsByTagsSuspenseQueryKey, + findPetsByTagsSuspenseQueryOptionsHook, + useFindPetsByTagsSuspenseHook, +} from './hooks/pet/useFindPetsByTagsSuspenseHook.ts' +export { getPetByIdQueryKey, getPetByIdQueryOptionsHook, useGetPetByIdHook } from './hooks/pet/useGetPetByIdHook.ts' +export { getPetByIdSuspenseQueryKey, getPetByIdSuspenseQueryOptionsHook, useGetPetByIdSuspenseHook } from './hooks/pet/useGetPetByIdSuspenseHook.ts' +export { updatePetMutationKey, useUpdatePetHook } from './hooks/pet/useUpdatePetHook.ts' +export { updatePetWithFormQueryKey, updatePetWithFormQueryOptionsHook, useUpdatePetWithFormHook } from './hooks/pet/useUpdatePetWithFormHook.ts' export { updatePetWithFormSuspenseQueryKey, updatePetWithFormSuspenseQueryOptionsHook, useUpdatePetWithFormSuspenseHook, -} from './hooks/useUpdatePetWithFormSuspenseHook.ts' -export { updateUserMutationKey, useUpdateUserHook } from './hooks/useUpdateUserHook.ts' -export { uploadFileMutationKey, useUploadFileHook } from './hooks/useUploadFileHook.ts' +} from './hooks/pet/useUpdatePetWithFormSuspenseHook.ts' +export { uploadFileMutationKey, useUploadFileHook } from './hooks/pet/useUploadFileHook.ts' +export { deleteOrderMutationKey, useDeleteOrderHook } from './hooks/store/useDeleteOrderHook.ts' +export { getInventoryQueryKey, getInventoryQueryOptionsHook } from './hooks/store/useGetInventoryHook.ts' +export { getInventorySuspenseQueryKey, getInventorySuspenseQueryOptionsHook, useGetInventorySuspenseHook } from './hooks/store/useGetInventorySuspenseHook.ts' +export { getOrderByIdQueryKey, getOrderByIdQueryOptionsHook, useGetOrderByIdHook } from './hooks/store/useGetOrderByIdHook.ts' +export { getOrderByIdSuspenseQueryKey, getOrderByIdSuspenseQueryOptionsHook, useGetOrderByIdSuspenseHook } from './hooks/store/useGetOrderByIdSuspenseHook.ts' +export { placeOrderMutationKey, usePlaceOrderHook } from './hooks/store/usePlaceOrderHook.ts' +export { placeOrderPatchMutationKey, usePlaceOrderPatchHook } from './hooks/store/usePlaceOrderPatchHook.ts' +export { createUserMutationKey, useCreateUserHook } from './hooks/user/useCreateUserHook.ts' +export { createUsersWithListInputMutationKey, useCreateUsersWithListInputHook } from './hooks/user/useCreateUsersWithListInputHook.ts' +export { deleteUserMutationKey, useDeleteUserHook } from './hooks/user/useDeleteUserHook.ts' +export { getUserByNameQueryKey, getUserByNameQueryOptionsHook, useGetUserByNameHook } from './hooks/user/useGetUserByNameHook.ts' +export { + getUserByNameSuspenseQueryKey, + getUserByNameSuspenseQueryOptionsHook, + useGetUserByNameSuspenseHook, +} from './hooks/user/useGetUserByNameSuspenseHook.ts' +export { loginUserQueryKey, loginUserQueryOptionsHook, useLoginUserHook } from './hooks/user/useLoginUserHook.ts' +export { loginUserSuspenseQueryKey, loginUserSuspenseQueryOptionsHook, useLoginUserSuspenseHook } from './hooks/user/useLoginUserSuspenseHook.ts' +export { logoutUserQueryKey, logoutUserQueryOptionsHook, useLogoutUserHook } from './hooks/user/useLogoutUserHook.ts' +export { logoutUserSuspenseQueryKey, logoutUserSuspenseQueryOptionsHook, useLogoutUserSuspenseHook } from './hooks/user/useLogoutUserSuspenseHook.ts' +export { updateUserMutationKey, useUpdateUserHook } from './hooks/user/useUpdateUserHook.ts' export { addPetRequestStatusEnum } from './models/AddPetRequest.ts' export { findPetsByStatusQueryParamsStatusEnum } from './models/FindPetsByStatus.ts' export { orderStatusEnum, orderHttpStatusEnum } from './models/Order.ts' diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 9f8744e6d..21410f9d3 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -319,7 +319,7 @@ export type Group = { /** * Define a type where to group the files on */ - type: 'tag' + type: 'tag' | 'path' /** * Return the name of a group based on the group name, this will be used for the file and name generation */ diff --git a/packages/plugin-client/src/generators/groupedClientGenerator.tsx b/packages/plugin-client/src/generators/groupedClientGenerator.tsx index 1ad433a84..cc51919da 100644 --- a/packages/plugin-client/src/generators/groupedClientGenerator.tsx +++ b/packages/plugin-client/src/generators/groupedClientGenerator.tsx @@ -29,7 +29,7 @@ export const groupedClientGenerator = createReactGenerator({ name, extname: '.ts', pluginKey, - options: { tag }, + options: { group: tag }, }) const client = { diff --git a/packages/plugin-client/src/plugin.ts b/packages/plugin-client/src/plugin.ts index 91d89722d..ac8d395b1 100644 --- a/packages/plugin-client/src/plugin.ts +++ b/packages/plugin-client/src/plugin.ts @@ -49,12 +49,6 @@ export const pluginClient = createPlugin((options) => { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -63,6 +57,19 @@ export const pluginClient = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-faker/src/generators/fakerGenerator.tsx b/packages/plugin-faker/src/generators/fakerGenerator.tsx index a7b5c7ac1..59687c93d 100644 --- a/packages/plugin-faker/src/generators/fakerGenerator.tsx +++ b/packages/plugin-faker/src/generators/fakerGenerator.tsx @@ -13,7 +13,7 @@ export const fakerGenerator = createReactGenerator({ const { plugin, pluginManager, mode } = useApp() const oas = useOas() - const { getSchemas, getFile } = useOperationManager() + const { getSchemas, getFile, getGroup } = useOperationManager() const schemaManager = useSchemaManager() const file = getFile(operation) @@ -33,6 +33,7 @@ export const fakerGenerator = createReactGenerator({ const mapOperationSchema = ({ name, schema, description, ...options }: OperationSchemaType, i: number) => { const tree = schemaGenerator.parse({ schema, name }) const imports = schemaManager.getImports(tree) + const group = options.operation ? getGroup(options.operation, plugin.options.group) : undefined const faker = { name: schemaManager.getName(name, { type: 'function' }), @@ -41,7 +42,7 @@ export const fakerGenerator = createReactGenerator({ const type = { name: schemaManager.getName(name, { type: 'type', pluginKey: [pluginTsName] }), - file: schemaManager.getFile(options.operationName || name, { pluginKey: [pluginTsName], tag: options.operation?.getTags()[0]?.name }), + file: schemaManager.getFile(options.operationName || name, { pluginKey: [pluginTsName], group }), } const canOverride = tree.some( diff --git a/packages/plugin-faker/src/plugin.ts b/packages/plugin-faker/src/plugin.ts index fec2a3d07..fd26b8ac0 100644 --- a/packages/plugin-faker/src/plugin.ts +++ b/packages/plugin-faker/src/plugin.ts @@ -42,18 +42,13 @@ export const pluginFaker = createPlugin((options) => { mapper, override, regexGenerator, + group, }, pre: [pluginOasName, pluginTsName], resolvePath(baseName, pathMode, options) { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -62,6 +57,19 @@ export const pluginFaker = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-faker/src/types.ts b/packages/plugin-faker/src/types.ts index 54c084994..f550c0047 100644 --- a/packages/plugin-faker/src/types.ts +++ b/packages/plugin-faker/src/types.ts @@ -80,6 +80,7 @@ export type Options = { type ResolvedOptions = { output: Output + group: Options['group'] override: NonNullable dateType: NonNullable dateParser: NonNullable diff --git a/packages/plugin-msw/src/plugin.ts b/packages/plugin-msw/src/plugin.ts index 5353c51af..bf9eb2ef0 100644 --- a/packages/plugin-msw/src/plugin.ts +++ b/packages/plugin-msw/src/plugin.ts @@ -32,18 +32,13 @@ export const pluginMsw = createPlugin((options) => { options: { output, parser, + group, }, pre: [pluginOasName, pluginTsName, parser === 'faker' ? pluginFakerName : undefined].filter(Boolean), resolvePath(baseName, pathMode, options) { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -52,6 +47,19 @@ export const pluginMsw = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-msw/src/types.ts b/packages/plugin-msw/src/types.ts index aea4a1239..dbd1fa60f 100644 --- a/packages/plugin-msw/src/types.ts +++ b/packages/plugin-msw/src/types.ts @@ -49,6 +49,7 @@ export type Options = { } type ResolvedOptions = { output: Output + group: Options['group'] parser: NonNullable } diff --git a/packages/plugin-oas/src/hooks/useOperationManager.ts b/packages/plugin-oas/src/hooks/useOperationManager.ts index 19576d9a5..a74cd9313 100644 --- a/packages/plugin-oas/src/hooks/useOperationManager.ts +++ b/packages/plugin-oas/src/hooks/useOperationManager.ts @@ -2,7 +2,8 @@ import { useApp, useContext } from '@kubb/react' import { Oas } from '../components/Oas.tsx' -import type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core' +import type { FileMetaBase, Group, Plugin, ResolveNameParams } from '@kubb/core' + import type * as KubbFile from '@kubb/fs/types' import type { Operation, Operation as OperationType } from '@kubb/oas' import type { OperationSchemas } from '../types.ts' @@ -10,7 +11,7 @@ import type { OperationSchemas } from '../types.ts' type FileMeta = FileMetaBase & { pluginKey: Plugin['key'] name: string - tag?: string + group?: string } export type SchemaNames = { @@ -41,7 +42,7 @@ type UseOperationManagerResult = { suffix?: string pluginKey?: Plugin['key'] extname?: KubbFile.Extname - tag?: string + group?: string }, ) => KubbFile.File groupSchemasByName: ( @@ -52,6 +53,7 @@ type UseOperationManagerResult = { }, ) => SchemaNames getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas + getGroup: (operation: Operation, group: Group | undefined) => string | undefined } /** @@ -69,6 +71,16 @@ export function useOperationManager(): UseOperationManagerResult { }) } + const getGroup: UseOperationManagerResult['getGroup'] = (operation, group) => { + if (group?.type === 'tag') { + return operation.getTags().at(0)?.name + } + + if (group?.type === 'path') { + return operation.path + } + } + const getSchemas: UseOperationManagerResult['getSchemas'] = (operation, params) => { if (!generator) { throw new Error(`'generator' is not defined`) @@ -84,17 +96,17 @@ export function useOperationManager(): UseOperationManagerResult { }) } - //TODO replace tag with group const getFile: UseOperationManagerResult['getFile'] = ( operation, - { prefix, suffix, pluginKey = plugin.key, tag = operation.getTags().at(0)?.name, extname = '.ts' } = {}, + { prefix, suffix, pluginKey = plugin.key, group = getGroup(operation, (plugin.options as { group?: Group })?.group), extname = '.ts' } = {}, ) => { const name = getName(operation, { type: 'file', pluginKey, prefix, suffix }) + const file = pluginManager.getFile({ name, extname, pluginKey, - options: { type: 'file', pluginKey, tag }, + options: { type: 'file', pluginKey, group }, }) return { @@ -103,7 +115,7 @@ export function useOperationManager(): UseOperationManagerResult { ...file.meta, name, pluginKey, - tag, + group, }, } } @@ -198,5 +210,6 @@ export function useOperationManager(): UseOperationManagerResult { getFile, getSchemas, groupSchemasByName, + getGroup, } } diff --git a/packages/plugin-oas/src/hooks/useSchemaManager.ts b/packages/plugin-oas/src/hooks/useSchemaManager.ts index 4606b66df..e00ce1dc9 100644 --- a/packages/plugin-oas/src/hooks/useSchemaManager.ts +++ b/packages/plugin-oas/src/hooks/useSchemaManager.ts @@ -9,12 +9,12 @@ import { type Schema, schemaKeywords } from '../SchemaMapper' type FileMeta = FileMetaBase & { pluginKey: Plugin['key'] name: string - tag?: string + group?: string } type UseSchemaManagerResult = { getName: (name: string, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string - getFile: (name: string, params?: { pluginKey?: Plugin['key']; mode?: Mode; extname?: KubbFile.Extname; tag?: string }) => KubbFile.File + getFile: (name: string, params?: { pluginKey?: Plugin['key']; mode?: Mode; extname?: KubbFile.Extname; group?: string }) => KubbFile.File getImports: (tree: Array) => Array } @@ -31,15 +31,15 @@ export function useSchemaManager(): UseSchemaManagerResult { type, }) } - //TODO replace tag with group - const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', tag } = {}) => { + + const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginKey = plugin.key, extname = '.ts', group } = {}) => { const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginKey }) const file = pluginManager.getFile({ name: resolvedName, extname, pluginKey, - options: { type: 'file', pluginKey, tag }, + options: { type: 'file', pluginKey, group }, }) return { diff --git a/packages/plugin-oas/src/types.ts b/packages/plugin-oas/src/types.ts index aee9999c8..7ff77b8b8 100644 --- a/packages/plugin-oas/src/types.ts +++ b/packages/plugin-oas/src/types.ts @@ -8,7 +8,7 @@ import type { GetSchemasProps } from './utils/getSchemas.ts' export type ResolvePathOptions = { pluginKey?: Plugin['key'] - tag?: string + group?: string type?: ResolveNameParams['type'] } diff --git a/packages/plugin-react-query/src/plugin.ts b/packages/plugin-react-query/src/plugin.ts index 14ed6f703..46fafd15b 100644 --- a/packages/plugin-react-query/src/plugin.ts +++ b/packages/plugin-react-query/src/plugin.ts @@ -72,18 +72,13 @@ export const pluginReactQuery = createPlugin((options) => { paramsType, pathParamsType: paramsType === 'object' ? 'object' : pathParamsType, parser, + group, }, pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean), resolvePath(baseName, pathMode, options) { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -92,6 +87,19 @@ export const pluginReactQuery = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-react-query/src/types.ts b/packages/plugin-react-query/src/types.ts index 65b50ef48..167b96066 100644 --- a/packages/plugin-react-query/src/types.ts +++ b/packages/plugin-react-query/src/types.ts @@ -148,6 +148,7 @@ export type Options = { type ResolvedOptions = { output: Output + group: Options['group'] client: Required, 'baseURL'>> & { baseURL?: string } parser: Required> pathParamsType: NonNullable diff --git a/packages/plugin-solid-query/src/plugin.ts b/packages/plugin-solid-query/src/plugin.ts index d20259c90..6189410a7 100644 --- a/packages/plugin-solid-query/src/plugin.ts +++ b/packages/plugin-solid-query/src/plugin.ts @@ -53,18 +53,13 @@ export const pluginSolidQuery = createPlugin((options) => { paramsType, pathParamsType: paramsType === 'object' ? 'object' : pathParamsType, parser, + group, }, pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean), resolvePath(baseName, pathMode, options) { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -73,6 +68,19 @@ export const pluginSolidQuery = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-solid-query/src/types.ts b/packages/plugin-solid-query/src/types.ts index 5874980f8..60cc0375d 100644 --- a/packages/plugin-solid-query/src/types.ts +++ b/packages/plugin-solid-query/src/types.ts @@ -95,6 +95,7 @@ export type Options = { type ResolvedOptions = { output: Output + group: Options['group'] client: Required, 'baseURL'>> & { baseURL?: string } parser: Required> paramsType: NonNullable diff --git a/packages/plugin-svelte-query/src/plugin.ts b/packages/plugin-svelte-query/src/plugin.ts index 9b6357b9d..a9b3e7af2 100644 --- a/packages/plugin-svelte-query/src/plugin.ts +++ b/packages/plugin-svelte-query/src/plugin.ts @@ -61,18 +61,13 @@ export const pluginSvelteQuery = createPlugin((options) => { paramsType, pathParamsType: paramsType === 'object' ? 'object' : pathParamsType, parser, + group, }, pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean), resolvePath(baseName, pathMode, options) { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -81,6 +76,19 @@ export const pluginSvelteQuery = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-svelte-query/src/types.ts b/packages/plugin-svelte-query/src/types.ts index bb86cf463..eb264246e 100644 --- a/packages/plugin-svelte-query/src/types.ts +++ b/packages/plugin-svelte-query/src/types.ts @@ -122,6 +122,7 @@ export type Options = { type ResolvedOptions = { output: Output + group: Options['group'] client: Required, 'baseURL'>> & { baseURL?: string } parser: Required> paramsType: NonNullable diff --git a/packages/plugin-swr/src/plugin.ts b/packages/plugin-swr/src/plugin.ts index 73a586a67..a6bfb75c7 100644 --- a/packages/plugin-swr/src/plugin.ts +++ b/packages/plugin-swr/src/plugin.ts @@ -61,18 +61,13 @@ export const pluginSwr = createPlugin((options) => { parser, paramsType, pathParamsType: paramsType === 'object' ? 'object' : pathParamsType, + group, }, pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean), resolvePath(baseName, pathMode, options) { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -81,6 +76,19 @@ export const pluginSwr = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-swr/src/types.ts b/packages/plugin-swr/src/types.ts index 2e54527f9..02b42bd2c 100644 --- a/packages/plugin-swr/src/types.ts +++ b/packages/plugin-swr/src/types.ts @@ -121,6 +121,7 @@ type ResolvedOptions = { mutation: NonNullable> | false paramsType: NonNullable pathParamsType: NonNullable + group: Options['group'] } export type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions> diff --git a/packages/plugin-ts/src/generators/typeGenerator.tsx b/packages/plugin-ts/src/generators/typeGenerator.tsx index c0d661f6a..137d967dc 100644 --- a/packages/plugin-ts/src/generators/typeGenerator.tsx +++ b/packages/plugin-ts/src/generators/typeGenerator.tsx @@ -108,7 +108,7 @@ export const typeGenerator = createReactGenerator({ const { plugin, pluginManager, mode } = useApp() const oas = useOas() - const { getSchemas, getFile, getName } = useOperationManager() + const { getSchemas, getFile, getName, getGroup } = useOperationManager() const schemaManager = useSchemaManager() const file = getFile(operation) @@ -130,11 +130,12 @@ export const typeGenerator = createReactGenerator({ const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options }: OperationSchemaType, i: number) => { const tree = schemaGenerator.parse({ schema, name }) const imports = schemaManager.getImports(tree) + const group = options.operation ? getGroup(options.operation, plugin.options.group) : undefined const type = { name: schemaManager.getName(name, { type: 'type' }), typedName: schemaManager.getName(name, { type: 'type' }), - file: schemaManager.getFile(options.operationName || name, { tag: options.operation?.getTags()[0]?.name }), + file: schemaManager.getFile(options.operationName || name, { group }), } return ( diff --git a/packages/plugin-ts/src/plugin.ts b/packages/plugin-ts/src/plugin.ts index c67fcbb65..fd5140d4a 100644 --- a/packages/plugin-ts/src/plugin.ts +++ b/packages/plugin-ts/src/plugin.ts @@ -42,6 +42,7 @@ export const pluginTs = createPlugin((options) => { // keep the used enumnames between SchemaGenerator and OperationGenerator per plugin(pluginKey) usedEnumNames: {}, unknownType, + group, override, mapper, }, @@ -50,12 +51,6 @@ export const pluginTs = createPlugin((options) => { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -64,6 +59,19 @@ export const pluginTs = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-ts/src/types.ts b/packages/plugin-ts/src/types.ts index 6b8d163dd..ebefb2026 100644 --- a/packages/plugin-ts/src/types.ts +++ b/packages/plugin-ts/src/types.ts @@ -82,6 +82,7 @@ export type Options = { type ResolvedOptions = { output: Output + group: Options['group'] override: NonNullable enumType: NonNullable enumSuffix: NonNullable diff --git a/packages/plugin-vue-query/src/plugin.ts b/packages/plugin-vue-query/src/plugin.ts index a3a8b8d8a..b2a8a9c29 100644 --- a/packages/plugin-vue-query/src/plugin.ts +++ b/packages/plugin-vue-query/src/plugin.ts @@ -70,18 +70,13 @@ export const pluginVueQuery = createPlugin((options) => { paramsType, pathParamsType: paramsType === 'object' ? 'object' : pathParamsType, parser, + group, }, pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean), resolvePath(baseName, pathMode, options) { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -90,6 +85,19 @@ export const pluginVueQuery = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-vue-query/src/types.ts b/packages/plugin-vue-query/src/types.ts index 8516d0d9c..580933700 100644 --- a/packages/plugin-vue-query/src/types.ts +++ b/packages/plugin-vue-query/src/types.ts @@ -142,6 +142,7 @@ export type Options = { type ResolvedOptions = { output: Output + group: Options['group'] client: Required, 'baseURL'>> & { baseURL?: string } parser: Required> paramsType: NonNullable diff --git a/packages/plugin-zod/src/generators/zodGenerator.tsx b/packages/plugin-zod/src/generators/zodGenerator.tsx index 45e983fdf..426d52eed 100644 --- a/packages/plugin-zod/src/generators/zodGenerator.tsx +++ b/packages/plugin-zod/src/generators/zodGenerator.tsx @@ -13,7 +13,7 @@ export const zodGenerator = createReactGenerator({ const { plugin, pluginManager, mode } = useApp() const oas = useOas() - const { getSchemas, getFile } = useOperationManager() + const { getSchemas, getFile, getGroup } = useOperationManager() const schemaManager = useSchemaManager() const file = getFile(operation) @@ -36,6 +36,7 @@ export const zodGenerator = createReactGenerator({ const optional = !required && !!name.includes('Params') const tree = [...schemaGenerator.parse({ schema, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean) const imports = schemaManager.getImports(tree) + const group = options.operation ? getGroup(options.operation, plugin.options.group) : undefined const zod = { name: schemaManager.getName(name, { type: 'function' }), @@ -45,7 +46,7 @@ export const zodGenerator = createReactGenerator({ const type = { name: schemaManager.getName(name, { type: 'type', pluginKey: [pluginTsName] }), - file: schemaManager.getFile(options.operationName || name, { pluginKey: [pluginTsName], tag: options.operation?.getTags()[0]?.name }), + file: schemaManager.getFile(options.operationName || name, { pluginKey: [pluginTsName], group }), } return ( diff --git a/packages/plugin-zod/src/plugin.ts b/packages/plugin-zod/src/plugin.ts index 7e7fe596d..b38ebe2f2 100644 --- a/packages/plugin-zod/src/plugin.ts +++ b/packages/plugin-zod/src/plugin.ts @@ -49,18 +49,13 @@ export const pluginZod = createPlugin((options) => { coercion, operations, inferred, + group, }, pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean), resolvePath(baseName, pathMode, options) { const root = path.resolve(this.config.root, this.config.output.path) const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path)) - if (options?.tag && group?.type === 'tag') { - const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller` - - return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName) - } - if (mode === 'single') { /** * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend @@ -69,6 +64,19 @@ export const pluginZod = createPlugin((options) => { return path.resolve(root, output.path) } + if (options?.group && group) { + const groupName: Group['name'] = 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: options.group }), baseName) + } + return path.resolve(root, output.path, baseName) }, resolveName(name, type) { diff --git a/packages/plugin-zod/src/types.ts b/packages/plugin-zod/src/types.ts index fefc651d5..df422a88d 100644 --- a/packages/plugin-zod/src/types.ts +++ b/packages/plugin-zod/src/types.ts @@ -91,6 +91,7 @@ export type Options = { type ResolvedOptions = { output: Output + group: Options['group'] override: NonNullable transformers: NonNullable dateType: NonNullable