콘솔에 발급된 설정이 설계와 어긋나 있었다. 클라이언트 시크릿이 켜져 있고 Redirect URI 가
프론트 경로(/auth/kakao/callback)인데, 코드는 "프론트가 액세스 토큰을 들고 온다" 는
전제였다 — 시크릿을 번들에 구울 수 없으므로 그 흐름으로는 토큰을 받을 수 없다.
- services/external/kakao_identity: access_token 검증 → **인가 코드 교환**으로 교체.
★ 우리 REST 키·시크릿으로 교환한 토큰이라 정의상 우리 앱 것이다 — 구글의 aud 대조에
해당하는 검사(KAKAO_LOGIN_APP_ID)가 구조적으로 필요 없어져 설정 칸째로 지웠다.
★ 로그인 앱과 챗봇 앱이 다르면 로그인은 되는데 채널 매칭만 조용히 안 된다 —
REST 키가 어긋나면 경고 로그를 남긴다.
★ 미인증 이메일은 신원으로 쓰지 않는다(is_email_valid·is_email_verified 둘 다). 이 값으로
auth_service 가 다른 수단 가입과의 충돌을 판정한다.
- config/config_models: KAKAO_LOGIN_APP_ID → REST_API_KEY · CLIENT_SECRET · REDIRECT_URI
- router/v1/auth: Req_KakaoLogin {access_token} → {code, redirect_uri}
- frontend: lib/kakaoIdentity(인가 URL · sessionStorage state) · KakaoSignInButton ·
pages/KakaoCallbackPage(코드는 1회용이라 ref 로 한 번만 보낸다) · routes
★ 로그인 폼에서 카카오를 구글 위에 둔다 — 이 수단으로 들어와야 6자리 코드 없이 채널이 이어진다
- compose · nginx/Dockerfile: REST 키·Redirect URI 만 프론트로 흘려보낸다. 시크릿은 안 나간다
- 어드민 키는 저장하지 않는다 — 탈퇴까지 되는 키인데 로그인에는 쓰이지 않는다
- api/generated: orval 재생성. 카카오 외에도 오래 밀려 있던 문구·agent 경로가 함께 따라왔다
테스트 8건 추가(tests/test_kakao_identity.py), 관련 85 passed
(test_auth::test_google_login_is_off_when_client_id_is_empty 는 기존 실패)
lint(react-router typegen + tsc + eslint) 통과
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1076 lines
28 KiB
TypeScript
1076 lines
28 KiB
TypeScript
/**
|
|
* Generated by orval v7.21.0 🍺
|
|
* Do not edit manually.
|
|
* Web4Ai API
|
|
* 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 {
|
|
GetGuideParams,
|
|
GetWeatherParams,
|
|
HTTPValidationError,
|
|
ListContentsParams,
|
|
ReqHidePlaceContent,
|
|
ReqPublishLocalContent,
|
|
ReqUpdateLocalContent,
|
|
ResLocalContentList,
|
|
ResLocalGuide,
|
|
ResPlaceContentList,
|
|
ResSyncPlace,
|
|
ResWeather,
|
|
} from ".././model";
|
|
|
|
import { customFetch } from "../../mutator/custom-fetch";
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
/**
|
|
* @summary 업장 주변정보 목록 (숨김 포함)
|
|
*/
|
|
export const listPlaceContents = (
|
|
placeId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResPlaceContentList>(
|
|
{ url: `/v1/admin/local-content/place/${placeId}`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getListPlaceContentsQueryKey = (placeId?: string) => {
|
|
return [`/v1/admin/local-content/place/${placeId}`] as const;
|
|
};
|
|
|
|
export const getListPlaceContentsQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey =
|
|
queryOptions?.queryKey ?? getListPlaceContentsQueryKey(placeId);
|
|
|
|
const queryFn: QueryFunction<
|
|
Awaited<ReturnType<typeof listPlaceContents>>
|
|
> = ({ signal }) => listPlaceContents(placeId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<
|
|
Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type ListPlaceContentsQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof listPlaceContents>>
|
|
>;
|
|
export type ListPlaceContentsQueryError = HTTPValidationError;
|
|
|
|
export function useListPlaceContents<
|
|
TData = Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listPlaceContents>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListPlaceContents<
|
|
TData = Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listPlaceContents>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListPlaceContents<
|
|
TData = Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 업장 주변정보 목록 (숨김 포함)
|
|
*/
|
|
|
|
export function useListPlaceContents<
|
|
TData = Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listPlaceContents>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getListPlaceContentsQueryOptions(placeId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* 빌드가 매번 하는 것과 같은 수집을 운영자가 직접 누른다.
|
|
* @summary 업장 주변정보 재수집 (TourAPI 반경)
|
|
*/
|
|
export const syncPlace = (
|
|
placeId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResSyncPlace>(
|
|
{
|
|
url: `/v1/admin/local-content/place/${placeId}/sync`,
|
|
method: "POST",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSyncPlaceMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof syncPlace>>,
|
|
TError,
|
|
{ placeId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof syncPlace>>,
|
|
TError,
|
|
{ placeId: string },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["syncPlace"];
|
|
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 syncPlace>>,
|
|
{ placeId: string }
|
|
> = (props) => {
|
|
const { placeId } = props ?? {};
|
|
|
|
return syncPlace(placeId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SyncPlaceMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof syncPlace>>
|
|
>;
|
|
|
|
export type SyncPlaceMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 업장 주변정보 재수집 (TourAPI 반경)
|
|
*/
|
|
export const useSyncPlace = <TError = HTTPValidationError, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof syncPlace>>,
|
|
TError,
|
|
{ placeId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof syncPlace>>,
|
|
TError,
|
|
{ placeId: string },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSyncPlaceMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 숨긴 항목은 재수집이 되살리지 않는다.
|
|
* @summary 주변정보 숨김/해제
|
|
*/
|
|
export const hidePlaceContent = (
|
|
placeContentId: string,
|
|
reqHidePlaceContent: ReqHidePlaceContent,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResPlaceContentList>(
|
|
{
|
|
url: `/v1/admin/local-content/place-content/${placeContentId}/hide`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqHidePlaceContent,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getHidePlaceContentMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof hidePlaceContent>>,
|
|
TError,
|
|
{ placeContentId: string; data: ReqHidePlaceContent },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof hidePlaceContent>>,
|
|
TError,
|
|
{ placeContentId: string; data: ReqHidePlaceContent },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["hidePlaceContent"];
|
|
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 hidePlaceContent>>,
|
|
{ placeContentId: string; data: ReqHidePlaceContent }
|
|
> = (props) => {
|
|
const { placeContentId, data } = props ?? {};
|
|
|
|
return hidePlaceContent(placeContentId, data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type HidePlaceContentMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof hidePlaceContent>>
|
|
>;
|
|
export type HidePlaceContentMutationBody = ReqHidePlaceContent;
|
|
export type HidePlaceContentMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 주변정보 숨김/해제
|
|
*/
|
|
export const useHidePlaceContent = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof hidePlaceContent>>,
|
|
TError,
|
|
{ placeContentId: string; data: ReqHidePlaceContent },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof hidePlaceContent>>,
|
|
TError,
|
|
{ placeContentId: string; data: ReqHidePlaceContent },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getHidePlaceContentMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary List Contents
|
|
*/
|
|
export const listContents = (
|
|
params?: ListContentsParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResLocalContentList>(
|
|
{ url: `/v1/admin/local-content`, method: "GET", params, signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getListContentsQueryKey = (params?: ListContentsParams) => {
|
|
return [`/v1/admin/local-content`, ...(params ? [params] : [])] as const;
|
|
};
|
|
|
|
export const getListContentsQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof listContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params?: ListContentsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listContents>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getListContentsQueryKey(params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof listContents>>> = ({
|
|
signal,
|
|
}) => listContents(params, requestOptions, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof listContents>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type ListContentsQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof listContents>>
|
|
>;
|
|
export type ListContentsQueryError = HTTPValidationError;
|
|
|
|
export function useListContents<
|
|
TData = Awaited<ReturnType<typeof listContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: undefined | ListContentsParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listContents>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listContents>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listContents>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListContents<
|
|
TData = Awaited<ReturnType<typeof listContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params?: ListContentsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listContents>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listContents>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listContents>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListContents<
|
|
TData = Awaited<ReturnType<typeof listContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params?: ListContentsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listContents>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary List Contents
|
|
*/
|
|
|
|
export function useListContents<
|
|
TData = Awaited<ReturnType<typeof listContents>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params?: ListContentsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listContents>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getListContentsQueryOptions(params, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* @summary Publish
|
|
*/
|
|
export const publish = (
|
|
reqPublishLocalContent: ReqPublishLocalContent,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResLocalContentList>(
|
|
{
|
|
url: `/v1/admin/local-content/publish`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqPublishLocalContent,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getPublishMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof publish>>,
|
|
TError,
|
|
{ data: ReqPublishLocalContent },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof publish>>,
|
|
TError,
|
|
{ data: ReqPublishLocalContent },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["publish"];
|
|
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 publish>>,
|
|
{ data: ReqPublishLocalContent }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return publish(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type PublishMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof publish>>
|
|
>;
|
|
export type PublishMutationBody = ReqPublishLocalContent;
|
|
export type PublishMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary Publish
|
|
*/
|
|
export const usePublish = <TError = HTTPValidationError, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof publish>>,
|
|
TError,
|
|
{ data: ReqPublishLocalContent },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof publish>>,
|
|
TError,
|
|
{ data: ReqPublishLocalContent },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getPublishMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary Update Content
|
|
*/
|
|
export const updateContent = (
|
|
contentId: string,
|
|
reqUpdateLocalContent: ReqUpdateLocalContent,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
) => {
|
|
return customFetch<ResLocalContentList>(
|
|
{
|
|
url: `/v1/admin/local-content/${contentId}`,
|
|
method: "PATCH",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqUpdateLocalContent,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getUpdateContentMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateContent>>,
|
|
TError,
|
|
{ contentId: string; data: ReqUpdateLocalContent },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateContent>>,
|
|
TError,
|
|
{ contentId: string; data: ReqUpdateLocalContent },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["updateContent"];
|
|
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 updateContent>>,
|
|
{ contentId: string; data: ReqUpdateLocalContent }
|
|
> = (props) => {
|
|
const { contentId, data } = props ?? {};
|
|
|
|
return updateContent(contentId, data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type UpdateContentMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof updateContent>>
|
|
>;
|
|
export type UpdateContentMutationBody = ReqUpdateLocalContent;
|
|
export type UpdateContentMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary Update Content
|
|
*/
|
|
export const useUpdateContent = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateContent>>,
|
|
TError,
|
|
{ contentId: string; data: ReqUpdateLocalContent },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof updateContent>>,
|
|
TError,
|
|
{ contentId: string; data: ReqUpdateLocalContent },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getUpdateContentMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary End Content
|
|
*/
|
|
export const endContent = (
|
|
contentId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResLocalContentList>(
|
|
{ url: `/v1/admin/local-content/${contentId}/end`, method: "POST", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getEndContentMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof endContent>>,
|
|
TError,
|
|
{ contentId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof endContent>>,
|
|
TError,
|
|
{ contentId: string },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["endContent"];
|
|
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 endContent>>,
|
|
{ contentId: string }
|
|
> = (props) => {
|
|
const { contentId } = props ?? {};
|
|
|
|
return endContent(contentId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type EndContentMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof endContent>>
|
|
>;
|
|
|
|
export type EndContentMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary End Content
|
|
*/
|
|
export const useEndContent = <TError = HTTPValidationError, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof endContent>>,
|
|
TError,
|
|
{ contentId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof endContent>>,
|
|
TError,
|
|
{ contentId: string },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getEndContentMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 현재 날씨 조회 (cache-aside)
|
|
*/
|
|
export const getWeather = (
|
|
params: GetWeatherParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResWeather>(
|
|
{ url: `/v1/local/weather`, method: "GET", params, signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetWeatherQueryKey = (params?: GetWeatherParams) => {
|
|
return [`/v1/local/weather`, ...(params ? [params] : [])] as const;
|
|
};
|
|
|
|
export const getGetWeatherQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getWeather>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetWeatherParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getWeather>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetWeatherQueryKey(params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getWeather>>> = ({
|
|
signal,
|
|
}) => getWeather(params, requestOptions, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof getWeather>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type GetWeatherQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getWeather>>
|
|
>;
|
|
export type GetWeatherQueryError = HTTPValidationError;
|
|
|
|
export function useGetWeather<
|
|
TData = Awaited<ReturnType<typeof getWeather>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetWeatherParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getWeather>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getWeather>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getWeather>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetWeather<
|
|
TData = Awaited<ReturnType<typeof getWeather>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetWeatherParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getWeather>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getWeather>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getWeather>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetWeather<
|
|
TData = Awaited<ReturnType<typeof getWeather>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetWeatherParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getWeather>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 현재 날씨 조회 (cache-aside)
|
|
*/
|
|
|
|
export function useGetWeather<
|
|
TData = Awaited<ReturnType<typeof getWeather>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetWeatherParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getWeather>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetWeatherQueryOptions(params, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* 날씨와 같은 공개 조회다 — 운영자가 숨기지 않은 공공데이터만 나가므로 인증을 요구하지 않는다.
|
|
* @summary 업장 주변 가이드(맛집·명소·축제·코스) — 에디터 캔버스용
|
|
*/
|
|
export const getGuide = (
|
|
params: GetGuideParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResLocalGuide>(
|
|
{ url: `/v1/local/guide`, method: "GET", params, signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetGuideQueryKey = (params?: GetGuideParams) => {
|
|
return [`/v1/local/guide`, ...(params ? [params] : [])] as const;
|
|
};
|
|
|
|
export const getGetGuideQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getGuide>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetGuideParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGuide>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetGuideQueryKey(params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getGuide>>> = ({
|
|
signal,
|
|
}) => getGuide(params, requestOptions, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof getGuide>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type GetGuideQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getGuide>>
|
|
>;
|
|
export type GetGuideQueryError = HTTPValidationError;
|
|
|
|
export function useGetGuide<
|
|
TData = Awaited<ReturnType<typeof getGuide>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetGuideParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGuide>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getGuide>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getGuide>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetGuide<
|
|
TData = Awaited<ReturnType<typeof getGuide>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetGuideParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGuide>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getGuide>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getGuide>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetGuide<
|
|
TData = Awaited<ReturnType<typeof getGuide>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetGuideParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGuide>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 업장 주변 가이드(맛집·명소·축제·코스) — 에디터 캔버스용
|
|
*/
|
|
|
|
export function useGetGuide<
|
|
TData = Awaited<ReturnType<typeof getGuide>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: GetGuideParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getGuide>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetGuideQueryOptions(params, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|