- 백엔드 SDK 이전: FastAPI OpenAPI → orval 자동생성 (React Query 훅 포함) - HTTP 어댑터: ky 기반 customFetcher, fetch httpClient 시그니처 - 아키텍처: features 모듈 / shared 레이어 컨벤션 정의 - 디자인 시스템: Tailwind v4 CSS-first 토큰 (브랜드 색 / status / shadcn) - 커스텀 CSS: utilities / animations 를 custom.css 로 분리 - Docker: 개발(Dockerfile.dev + compose) / 프로덕션(nginx) 셋업 - README: 기술 스펙 / 프로젝트 구조 / 디자인 토큰 / 폰트 / SDK 사용법 정리 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
248 lines
7.1 KiB
TypeScript
248 lines
7.1 KiB
TypeScript
/**
|
|
* Generated by orval v7.21.0 🍺
|
|
* Do not edit manually.
|
|
* FastAPI
|
|
* OpenAPI spec version: 0.1.0
|
|
*/
|
|
import {
|
|
useMutation,
|
|
useQuery
|
|
} from '@tanstack/react-query';
|
|
import type {
|
|
DataTag,
|
|
DefinedInitialDataOptions,
|
|
DefinedUseQueryResult,
|
|
MutationFunction,
|
|
QueryClient,
|
|
QueryFunction,
|
|
QueryKey,
|
|
UndefinedInitialDataOptions,
|
|
UseMutationOptions,
|
|
UseMutationResult,
|
|
UseQueryOptions,
|
|
UseQueryResult
|
|
} from '@tanstack/react-query';
|
|
|
|
import type {
|
|
HTTPValidationError,
|
|
PlanCreate,
|
|
PlanResponse
|
|
} from '../../model';
|
|
|
|
import { customFetcher } from '../../api';
|
|
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
|
|
|
|
/**
|
|
* @summary Create Plan
|
|
*/
|
|
export type createPlanResponse201 = {
|
|
data: PlanResponse
|
|
status: 201
|
|
}
|
|
|
|
export type createPlanResponse422 = {
|
|
data: HTTPValidationError
|
|
status: 422
|
|
}
|
|
|
|
export type createPlanResponseSuccess = (createPlanResponse201) & {
|
|
headers: Headers;
|
|
};
|
|
export type createPlanResponseError = (createPlanResponse422) & {
|
|
headers: Headers;
|
|
};
|
|
|
|
export type createPlanResponse = (createPlanResponseSuccess | createPlanResponseError)
|
|
|
|
export const getCreatePlanUrl = () => {
|
|
|
|
|
|
|
|
|
|
return `/api/plans`
|
|
}
|
|
|
|
export const createPlan = async (planCreate: PlanCreate, options?: RequestInit): Promise<createPlanResponse> => {
|
|
|
|
return customFetcher<createPlanResponse>(getCreatePlanUrl(),
|
|
{
|
|
...options,
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json', ...options?.headers },
|
|
body: JSON.stringify(
|
|
planCreate,)
|
|
}
|
|
);}
|
|
|
|
|
|
|
|
|
|
export const getCreatePlanMutationOptions = <TError = HTTPValidationError,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createPlan>>, TError,{data: PlanCreate}, TContext>, request?: SecondParameter<typeof customFetcher>}
|
|
): UseMutationOptions<Awaited<ReturnType<typeof createPlan>>, TError,{data: PlanCreate}, TContext> => {
|
|
|
|
const mutationKey = ['createPlan'];
|
|
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
options
|
|
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
: {mutation: { mutationKey, }, request: undefined};
|
|
|
|
|
|
|
|
|
|
const mutationFn: MutationFunction<Awaited<ReturnType<typeof createPlan>>, {data: PlanCreate}> = (props) => {
|
|
const {data} = props ?? {};
|
|
|
|
return createPlan(data,requestOptions)
|
|
}
|
|
|
|
|
|
|
|
|
|
return { mutationFn, ...mutationOptions }}
|
|
|
|
export type CreatePlanMutationResult = NonNullable<Awaited<ReturnType<typeof createPlan>>>
|
|
export type CreatePlanMutationBody = PlanCreate
|
|
export type CreatePlanMutationError = HTTPValidationError
|
|
|
|
/**
|
|
* @summary Create Plan
|
|
*/
|
|
export const useCreatePlan = <TError = HTTPValidationError,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createPlan>>, TError,{data: PlanCreate}, TContext>, request?: SecondParameter<typeof customFetcher>}
|
|
, queryClient?: QueryClient): UseMutationResult<
|
|
Awaited<ReturnType<typeof createPlan>>,
|
|
TError,
|
|
{data: PlanCreate},
|
|
TContext
|
|
> => {
|
|
|
|
const mutationOptions = getCreatePlanMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
}
|
|
/**
|
|
* @summary Get Plan
|
|
*/
|
|
export type getPlanResponse200 = {
|
|
data: PlanResponse
|
|
status: 200
|
|
}
|
|
|
|
export type getPlanResponse422 = {
|
|
data: HTTPValidationError
|
|
status: 422
|
|
}
|
|
|
|
export type getPlanResponseSuccess = (getPlanResponse200) & {
|
|
headers: Headers;
|
|
};
|
|
export type getPlanResponseError = (getPlanResponse422) & {
|
|
headers: Headers;
|
|
};
|
|
|
|
export type getPlanResponse = (getPlanResponseSuccess | getPlanResponseError)
|
|
|
|
export const getGetPlanUrl = (id: string,) => {
|
|
|
|
|
|
|
|
|
|
return `/api/plans/${id}`
|
|
}
|
|
|
|
export const getPlan = async (id: string, options?: RequestInit): Promise<getPlanResponse> => {
|
|
|
|
return customFetcher<getPlanResponse>(getGetPlanUrl(id),
|
|
{
|
|
...options,
|
|
method: 'GET'
|
|
|
|
|
|
}
|
|
);}
|
|
|
|
|
|
|
|
|
|
|
|
export const getGetPlanQueryKey = (id?: string,) => {
|
|
return [
|
|
`/api/plans/${id}`
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getGetPlanQueryOptions = <TData = Awaited<ReturnType<typeof getPlan>>, TError = HTTPValidationError>(id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getPlan>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetPlanQueryKey(id);
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getPlan>>> = () => getPlan(id, requestOptions);
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, enabled: !!(id), staleTime: 60000, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getPlan>>, TError, TData> & { queryKey: DataTag<QueryKey, TData> }
|
|
}
|
|
|
|
export type GetPlanQueryResult = NonNullable<Awaited<ReturnType<typeof getPlan>>>
|
|
export type GetPlanQueryError = HTTPValidationError
|
|
|
|
|
|
export function useGetPlan<TData = Awaited<ReturnType<typeof getPlan>>, TError = HTTPValidationError>(
|
|
id: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getPlan>>, TError, TData>> & Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getPlan>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getPlan>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customFetcher>}
|
|
, queryClient?: QueryClient
|
|
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
|
|
export function useGetPlan<TData = Awaited<ReturnType<typeof getPlan>>, TError = HTTPValidationError>(
|
|
id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getPlan>>, TError, TData>> & Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getPlan>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getPlan>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customFetcher>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
|
|
export function useGetPlan<TData = Awaited<ReturnType<typeof getPlan>>, TError = HTTPValidationError>(
|
|
id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getPlan>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
|
|
/**
|
|
* @summary Get Plan
|
|
*/
|
|
|
|
export function useGetPlan<TData = Awaited<ReturnType<typeof getPlan>>, TError = HTTPValidationError>(
|
|
id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getPlan>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {
|
|
|
|
const queryOptions = getGetPlanQueryOptions(id,options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> };
|
|
|
|
query.queryKey = queryOptions.queryKey ;
|
|
|
|
return query;
|
|
}
|
|
|
|
|
|
|
|
|