- OWNER 권한 신설, 최고관리자가 자기 회사 소속 직원(USER) 계정 생성·수정·삭제 관리 - 회사 사용자 API(/v1/company/user/*), 회원관리 페이지·폼 - 로그인/프로필 흐름 정비, 무인증 계정생성(/auth/create) 제거 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
327 lines
10 KiB
TypeScript
327 lines
10 KiB
TypeScript
/**
|
|
* Generated by orval v7.21.0 🍺
|
|
* Do not edit manually.
|
|
* Negodata Api Server
|
|
* 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,
|
|
ReqLogin,
|
|
ReqUpdateMe,
|
|
ResLogin,
|
|
ResMe,
|
|
ResRefreshToken
|
|
} from '.././model';
|
|
|
|
import { customFetch } from '../../mutator/custom-fetch';
|
|
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
|
|
|
|
/**
|
|
* id/pw 로 로그인하고 JWT 토큰을 발급한다.
|
|
* @summary 로그인
|
|
*/
|
|
export const login = (
|
|
reqLogin: ReqLogin,
|
|
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customFetch<ResLogin>(
|
|
{url: `/v1/auth/login`, method: 'POST',
|
|
headers: {'Content-Type': 'application/json', },
|
|
data: reqLogin, signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
export const getLoginMutationOptions = <TError = void | HTTPValidationError,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof login>>, TError,{data: ReqLogin}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
): UseMutationOptions<Awaited<ReturnType<typeof login>>, TError,{data: ReqLogin}, TContext> => {
|
|
|
|
const mutationKey = ['login'];
|
|
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 login>>, {data: ReqLogin}> = (props) => {
|
|
const {data} = props ?? {};
|
|
|
|
return login(data,requestOptions)
|
|
}
|
|
|
|
|
|
|
|
|
|
return { mutationFn, ...mutationOptions }}
|
|
|
|
export type LoginMutationResult = NonNullable<Awaited<ReturnType<typeof login>>>
|
|
export type LoginMutationBody = ReqLogin
|
|
export type LoginMutationError = void | HTTPValidationError
|
|
|
|
/**
|
|
* @summary 로그인
|
|
*/
|
|
export const useLogin = <TError = void | HTTPValidationError,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof login>>, TError,{data: ReqLogin}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient): UseMutationResult<
|
|
Awaited<ReturnType<typeof login>>,
|
|
TError,
|
|
{data: ReqLogin},
|
|
TContext
|
|
> => {
|
|
|
|
const mutationOptions = getLoginMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
}
|
|
/**
|
|
* refresh 토큰으로 access 토큰을 재발급한다.
|
|
* @summary 액세스 토큰 갱신
|
|
*/
|
|
export const refreshToken = (
|
|
|
|
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customFetch<ResRefreshToken>(
|
|
{url: `/v1/auth/refresh_token`, method: 'POST', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
export const getRefreshTokenMutationOptions = <TError = void,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof refreshToken>>, TError,void, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
): UseMutationOptions<Awaited<ReturnType<typeof refreshToken>>, TError,void, TContext> => {
|
|
|
|
const mutationKey = ['refreshToken'];
|
|
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 refreshToken>>, void> = () => {
|
|
|
|
|
|
return refreshToken(requestOptions)
|
|
}
|
|
|
|
|
|
|
|
|
|
return { mutationFn, ...mutationOptions }}
|
|
|
|
export type RefreshTokenMutationResult = NonNullable<Awaited<ReturnType<typeof refreshToken>>>
|
|
|
|
export type RefreshTokenMutationError = void
|
|
|
|
/**
|
|
* @summary 액세스 토큰 갱신
|
|
*/
|
|
export const useRefreshToken = <TError = void,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof refreshToken>>, TError,void, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient): UseMutationResult<
|
|
Awaited<ReturnType<typeof refreshToken>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
> => {
|
|
|
|
const mutationOptions = getRefreshTokenMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
}
|
|
/**
|
|
* 유효한 access 토큰이 있어야 호출 가능. 토큰의 유저+회사 정보를 반환한다.
|
|
* @summary 내 정보
|
|
*/
|
|
export const me = (
|
|
|
|
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customFetch<ResMe>(
|
|
{url: `/v1/auth/me`, method: 'GET', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getMeQueryKey = () => {
|
|
return [
|
|
`/v1/auth/me`
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getMeQueryOptions = <TData = Awaited<ReturnType<typeof me>>, TError = void>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getMeQueryKey();
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof me>>> = ({ signal }) => me(requestOptions, signal);
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
}
|
|
|
|
export type MeQueryResult = NonNullable<Awaited<ReturnType<typeof me>>>
|
|
export type MeQueryError = void
|
|
|
|
|
|
export function useMe<TData = Awaited<ReturnType<typeof me>>, TError = void>(
|
|
options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>> & Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof me>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof me>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient
|
|
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useMe<TData = Awaited<ReturnType<typeof me>>, TError = void>(
|
|
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>> & Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof me>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof me>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useMe<TData = Awaited<ReturnType<typeof me>>, TError = void>(
|
|
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
/**
|
|
* @summary 내 정보
|
|
*/
|
|
|
|
export function useMe<TData = Awaited<ReturnType<typeof me>>, TError = void>(
|
|
options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
|
|
const queryOptions = getMeQueryOptions(options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey ;
|
|
|
|
return query;
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 본인 이름/이메일/연락처/비밀번호를 수정한다(권한·소속·ID 변경 불가).
|
|
* @summary 내 정보 수정
|
|
*/
|
|
export const updateMe = (
|
|
reqUpdateMe: ReqUpdateMe,
|
|
options?: SecondParameter<typeof customFetch>,) => {
|
|
|
|
|
|
return customFetch<ResMe>(
|
|
{url: `/v1/auth/me`, method: 'PATCH',
|
|
headers: {'Content-Type': 'application/json', },
|
|
data: reqUpdateMe
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
export const getUpdateMeMutationOptions = <TError = void | HTTPValidationError,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateMe>>, TError,{data: ReqUpdateMe}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
): UseMutationOptions<Awaited<ReturnType<typeof updateMe>>, TError,{data: ReqUpdateMe}, TContext> => {
|
|
|
|
const mutationKey = ['updateMe'];
|
|
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 updateMe>>, {data: ReqUpdateMe}> = (props) => {
|
|
const {data} = props ?? {};
|
|
|
|
return updateMe(data,requestOptions)
|
|
}
|
|
|
|
|
|
|
|
|
|
return { mutationFn, ...mutationOptions }}
|
|
|
|
export type UpdateMeMutationResult = NonNullable<Awaited<ReturnType<typeof updateMe>>>
|
|
export type UpdateMeMutationBody = ReqUpdateMe
|
|
export type UpdateMeMutationError = void | HTTPValidationError
|
|
|
|
/**
|
|
* @summary 내 정보 수정
|
|
*/
|
|
export const useUpdateMe = <TError = void | HTTPValidationError,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateMe>>, TError,{data: ReqUpdateMe}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient): UseMutationResult<
|
|
Awaited<ReturnType<typeof updateMe>>,
|
|
TError,
|
|
{data: ReqUpdateMe},
|
|
TContext
|
|
> => {
|
|
|
|
const mutationOptions = getUpdateMeMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
}
|
|
|