Repository navigation
[FEAT] Swagger 기반 API 클라이언트 자동 생성 도입 (orval) #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
268426d
chore(root): orval 도입에 따른 의존성 정리 (#145)
kimminna a35739c
feat(web): Swagger 기반 API 클라이언트 자동 생성 도입 (#145)
kimminna a3fb42c
refactor(web): 미사용 apiResponseSchema 제거 (#145)
kimminna 9649447
comment(web): orval unsafeDisableValidation에 TODO 추가 (#145)
kimminna b45288b
fix(web): next-intl 정적 렌더링 활성화 (#145)
kimminna 24aa328
fix(web): locale 세그먼트 dynamicParams 비활성화 (#145)
kimminna 94e4f8d
fix(web): locale dynamicParams 설정 되돌리기 (#145)
kimminna a5542da
remove(web): settings 하위 경로 스텁 제거 (#145)
kimminna 579b281
Revert "remove(web): settings 하위 경로 스텁 제거 (#145)"
kimminna d23ff2f
Merge branch 'develop' of https://github.com/Team-Timo/Timo-client in…
kimminna 11fe4cb
fix(web): todo-schema.ts의 존재하지 않는 apiResponseSchema import 제거
kimminna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import type { AxiosError, AxiosRequestConfig } from "axios"; | ||
|
|
||
| import { instance } from "@/api/client/axios"; | ||
|
|
||
| export const customInstance = <T>( | ||
| config: AxiosRequestConfig, | ||
| options?: AxiosRequestConfig, | ||
| ): Promise<T> => | ||
| instance({ ...config, ...options }).then((response) => response.data); | ||
|
|
||
| export type ErrorType<TError> = AxiosError<TError>; | ||
| export type BodyType<TBodyData> = TBodyData; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| /** | ||
| * Generated by orval v8.20.0 🍺 | ||
| * Do not edit manually. | ||
| * Timo API | ||
| * Timo 서버 API 명세서 | ||
| * OpenAPI spec version: v1 | ||
| */ | ||
| import { useMutation } from "@tanstack/react-query"; | ||
|
|
||
| import { customInstance } from "../../../client/custom-instance"; | ||
|
|
||
| import type { ErrorType, BodyType } from "../../../client/custom-instance"; | ||
| import type { | ||
| BaseResponseRecommendDurationResponse, | ||
| ErrorDto, | ||
| RecommendDurationRequest, | ||
| } from "../../models"; | ||
| import type { | ||
| MutationFunction, | ||
| QueryClient, | ||
| UseMutationOptions, | ||
| UseMutationResult, | ||
| } from "@tanstack/react-query"; | ||
|
|
||
| type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]; | ||
|
|
||
| /** | ||
| * 투두명과 태그를 기준으로 예상 소요 시간을 추천합니다. | ||
| * | ||
| * 서버는 사용자의 타이머 기반 실제 소요시간 기록을 조회해 Gemini에 전달합니다. | ||
| * 1. 현재 투두명과 비슷한 과거 투두의 실제 소요시간 기록 | ||
| * 2. 사용자가 지정한 태그의 최근 실제 소요시간 기록 | ||
| * 3. 기록이 없으면 현재 투두명 기준 | ||
| * | ||
| * Gemini는 위 기록을 종합해 예상 소요 시간을 생성합니다. | ||
| * RPM, RPD, TPM 제한을 초과하면 Gemini 호출 전 429 응답을 반환합니다. | ||
| * @summary AI 예상 소요 시간 추천 | ||
| */ | ||
| export const recommendDuration = ( | ||
| recommendDurationRequest: BodyType<RecommendDurationRequest>, | ||
| options?: SecondParameter<typeof customInstance>, | ||
| signal?: AbortSignal, | ||
| ) => { | ||
| return customInstance<BaseResponseRecommendDurationResponse>( | ||
| { | ||
| url: `/api/v1/ai/duration`, | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| data: recommendDurationRequest, | ||
| signal, | ||
| }, | ||
| options, | ||
| ); | ||
| }; | ||
|
|
||
| export const getRecommendDurationMutationOptions = < | ||
| TError = ErrorType<ErrorDto>, | ||
| TContext = unknown, | ||
| >(options?: { | ||
| mutation?: UseMutationOptions< | ||
| Awaited<ReturnType<typeof recommendDuration>>, | ||
| TError, | ||
| { data: BodyType<RecommendDurationRequest> }, | ||
| TContext | ||
| >; | ||
| request?: SecondParameter<typeof customInstance>; | ||
| }): UseMutationOptions< | ||
| Awaited<ReturnType<typeof recommendDuration>>, | ||
| TError, | ||
| { data: BodyType<RecommendDurationRequest> }, | ||
| TContext | ||
| > => { | ||
| const mutationKey = ["recommendDuration"]; | ||
| 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 recommendDuration>>, | ||
| { data: BodyType<RecommendDurationRequest> } | ||
| > = (props) => { | ||
| const { data } = props ?? {}; | ||
|
|
||
| return recommendDuration(data, requestOptions); | ||
| }; | ||
|
|
||
| return { mutationFn, ...mutationOptions }; | ||
| }; | ||
|
|
||
| export type RecommendDurationMutationResult = NonNullable< | ||
| Awaited<ReturnType<typeof recommendDuration>> | ||
| >; | ||
| export type RecommendDurationMutationBody = BodyType<RecommendDurationRequest>; | ||
| export type RecommendDurationMutationError = ErrorType<ErrorDto>; | ||
|
|
||
| /** | ||
| * @summary AI 예상 소요 시간 추천 | ||
| */ | ||
| export const useRecommendDuration = < | ||
| TError = ErrorType<ErrorDto>, | ||
| TContext = unknown, | ||
| >( | ||
| options?: { | ||
| mutation?: UseMutationOptions< | ||
| Awaited<ReturnType<typeof recommendDuration>>, | ||
| TError, | ||
| { data: BodyType<RecommendDurationRequest> }, | ||
| TContext | ||
| >; | ||
| request?: SecondParameter<typeof customInstance>; | ||
| }, | ||
| queryClient?: QueryClient, | ||
| ): UseMutationResult< | ||
| Awaited<ReturnType<typeof recommendDuration>>, | ||
| TError, | ||
| { data: BodyType<RecommendDurationRequest> }, | ||
| TContext | ||
| > => { | ||
| return useMutation(getRecommendDurationMutationOptions(options), queryClient); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /** | ||
| * Generated by orval v8.20.0 🍺 | ||
| * Do not edit manually. | ||
| * Timo API | ||
| * Timo 서버 API 명세서 | ||
| * OpenAPI spec version: v1 | ||
| */ | ||
| import * as zod from "zod"; | ||
|
|
||
| /** | ||
| * 투두명과 태그를 기준으로 예상 소요 시간을 추천합니다. | ||
| * | ||
| * 서버는 사용자의 타이머 기반 실제 소요시간 기록을 조회해 Gemini에 전달합니다. | ||
| * 1. 현재 투두명과 비슷한 과거 투두의 실제 소요시간 기록 | ||
| * 2. 사용자가 지정한 태그의 최근 실제 소요시간 기록 | ||
| * 3. 기록이 없으면 현재 투두명 기준 | ||
| * | ||
| * Gemini는 위 기록을 종합해 예상 소요 시간을 생성합니다. | ||
| * RPM, RPD, TPM 제한을 초과하면 Gemini 호출 전 429 응답을 반환합니다. | ||
| * @summary AI 예상 소요 시간 추천 | ||
| */ | ||
| export const recommendDurationBodyTitleMin = 0; | ||
| export const recommendDurationBodyTitleMax = 30; | ||
|
|
||
| export const RecommendDurationBody = zod.object({ | ||
| title: zod | ||
| .string() | ||
| .min(recommendDurationBodyTitleMin) | ||
| .max(recommendDurationBodyTitleMax) | ||
| .describe("추천받을 투두명"), | ||
| tagId: zod.number().nullish().describe("투두 태그 ID"), | ||
| }); | ||
|
|
||
| export const RecommendDurationResponse = zod.unknown(); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.