/** * Generated by orval v8.20.0 🍺 * Do not edit manually. * Timo API * Timo μ„œλ²„ API λͺ…μ„Έμ„œ * OpenAPI spec version: v1 */ import { useMutation, useQuery } from "@tanstack/react-query"; import { customInstance } from "../../../http/custom-instance"; import type { ErrorType, BodyType } from "../../../http/custom-instance"; import type { BaseResponseTimerActiveResponse, BaseResponseTimerExtendResponse, BaseResponseTimerFinishResponse, BaseResponseTimerStartResponse, BaseResponseTimerStatusResponse, BaseResponseTimerSwitchResponse, ErrorDto, StartTimerParams, TimerActionRequest, TimerExtendRequest, TimerSwitchRequest, } from "../../models"; import type { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, MutationFunction, QueryClient, QueryFunction, QueryKey, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult, } from "@tanstack/react-query"; type SecondParameter unknown> = Parameters[1]; const withQueryKey = ( query: T, queryKey: K, ): T & { queryKey: K } => { const result = { queryKey } as T & { queryKey: K }; for (const key of Object.keys(query)) { // The explicit queryKey always wins, matching the previous // `{ ...query, queryKey }` spread where it was set last. if (key === "queryKey") continue; Object.defineProperty(result, key, { enumerable: true, configurable: true, get: () => (query as Record)[key], }); } return result; }; /** * νˆ¬λ‘μ˜ 타이머λ₯Ό μ‹œμž‘ν•©λ‹ˆλ‹€. * ν•œ λ²ˆμ— ν•œ 개의 νƒ€μ΄λ¨Έλ§Œ μ‹€ν–‰ κ°€λŠ₯ν•˜λ©°, 이미 μ‹€ν–‰/μΌμ‹œμ •μ§€ 쀑인 타이머가 있으면 409λ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€. * * 반볡 νˆ¬λ‘λŠ” μ—¬λŸ¬ λ‚ μ§œμ— 같은 todoId둜 λ…ΈμΆœλ˜λ―€λ‘œ, 싀행쀑 ν‘œμ‹œλŠ” todoIdκ°€ μ•„λ‹Œ (todoId, date) μ‘°ν•©μœΌλ‘œ ꡬ뢄해야 ν•©λ‹ˆλ‹€. * 쿼리 νŒŒλΌλ―Έν„° date둜 타이머가 μƒνƒœλ₯Ό λ°˜μ˜ν•  λŒ€μƒ λ‚ μ§œλ₯Ό μ§€μ •ν•  수 있으며(미래/κ³Όκ±° 포함), λ―Έμ§€μ • μ‹œ μ‚¬μš©μž νƒ€μž„μ‘΄ κΈ°μ€€ 였늘둜 μ²˜λ¦¬λ©λ‹ˆλ‹€. 이후 μΌμ‹œμ •μ§€/재개/μ™„λ£Œ/μ€‘μ§€λŠ” 이 λ‚ μ§œλ₯Ό κ·ΈλŒ€λ‘œ μ‚¬μš©ν•©λ‹ˆλ‹€. * @summary 타이머 μ‹œμž‘ */ export const startTimer = ( todoId: number, params?: StartTimerParams, options?: SecondParameter, signal?: AbortSignal, ) => { return customInstance( { url: `/api/v1/todos/${todoId}/timers/start`, method: "POST", params, signal, }, options, ); }; export const getStartTimerMutationOptions = < TError = ErrorType, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { todoId: number; params?: StartTimerParams }, TContext >; request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, { todoId: number; params?: StartTimerParams }, TContext > => { const mutationKey = ["startTimer"]; 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>, { todoId: number; params?: StartTimerParams } > = (props) => { const { todoId, params } = props ?? {}; return startTimer(todoId, params, requestOptions); }; return { mutationFn, ...mutationOptions }; }; export type StartTimerMutationResult = NonNullable< Awaited> >; export type StartTimerMutationError = ErrorType; /** * @summary 타이머 μ‹œμž‘ */ export const useStartTimer = , TContext = unknown>( options?: { mutation?: UseMutationOptions< Awaited>, TError, { todoId: number; params?: StartTimerParams }, TContext >; request?: SecondParameter; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { todoId: number; params?: StartTimerParams }, TContext > => { return useMutation(getStartTimerMutationOptions(options), queryClient); }; /** * μ§„ν–‰ 쀑인 타이머λ₯Ό μ’…λ£Œν•˜κ³ , μš”μ²­ν•œ νˆ¬λ‘μ˜ 타이머λ₯Ό λ°”λ‘œ μ‹œμž‘ν•©λ‹ˆλ‹€. * μ’…λ£Œλ˜λŠ” νƒ€μ΄λ¨ΈλŠ” 쀑지(stop)와 λ™μΌν•˜κ²Œ STOPPED μƒνƒœλ‘œ 처리되며 ν•΄λ‹Ή νˆ¬λ‘λŠ” μ™„λ£Œ μ²˜λ¦¬λ©λ‹ˆλ‹€. AI ν”Όλ“œλ°±μ€ μƒμ„±ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. * μ’…λ£Œμ™€ μ‹œμž‘μ€ ν•˜λ‚˜μ˜ νŠΈλžœμž­μ…˜μœΌλ‘œ μ²˜λ¦¬λ˜μ–΄ ν•œμͺ½λ§Œ λ°˜μ˜λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. * * 반볡 νˆ¬λ‘λŠ” μ—¬λŸ¬ λ‚ μ§œμ— 같은 todoId둜 λ…ΈμΆœλ˜λ―€λ‘œ, body의 date(ν•„μˆ˜)둜 μƒˆ 타이머가 μƒνƒœλ₯Ό λ°˜μ˜ν•  λŒ€μƒ λ‚ μ§œλ₯Ό μ§€μ •ν•©λ‹ˆλ‹€. * @summary 타이머 μ „ν™˜ */ export const switchTimer = ( timerId: number, timerSwitchRequest: BodyType, options?: SecondParameter, signal?: AbortSignal, ) => { return customInstance( { url: `/api/v1/timers/${timerId}/switch`, method: "PATCH", headers: { "Content-Type": "application/json" }, data: timerSwitchRequest, signal, }, options, ); }; export const getSwitchTimerMutationOptions = < TError = ErrorType, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number; data: BodyType }, TContext >; request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, { timerId: number; data: BodyType }, TContext > => { const mutationKey = ["switchTimer"]; 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>, { timerId: number; data: BodyType } > = (props) => { const { timerId, data } = props ?? {}; return switchTimer(timerId, data, requestOptions); }; return { mutationFn, ...mutationOptions }; }; export type SwitchTimerMutationResult = NonNullable< Awaited> >; export type SwitchTimerMutationBody = BodyType; export type SwitchTimerMutationError = ErrorType; /** * @summary 타이머 μ „ν™˜ */ export const useSwitchTimer = < TError = ErrorType, TContext = unknown, >( options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number; data: BodyType }, TContext >; request?: SecondParameter; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { timerId: number; data: BodyType }, TContext > => { return useMutation(getSwitchTimerMutationOptions(options), queryClient); }; /** * μ‚¬μš©μžμ˜ μš”μ²­μœΌλ‘œ 타이머λ₯Ό μ’…λ£Œν•©λ‹ˆλ‹€. * μ’…λ£Œ μ‹œκ° 기둝, μ‹€μ œ μˆ˜ν–‰ μ‹œκ°„ 계산 (status β†’ STOPPED) * ν•΄λ‹Ή λ‚ μ§œ TodoInstance μ™„λ£Œ 처리 및 타이머 μƒνƒœ μ΄ˆκΈ°ν™” * κ³„νš μ‹œκ°„κ³Ό μ‹€μ œ μˆ˜ν–‰ 기둝을 λΆ„μ„ν•œ AI ν”Όλ“œλ°± λ°˜ν™˜ * @summary 타이머 μ’…λ£Œ */ export const stopTimer = ( timerId: number, options?: SecondParameter, signal?: AbortSignal, ) => { return customInstance( { url: `/api/v1/timers/${timerId}/stop`, method: "PATCH", signal }, options, ); }; export const getStopTimerMutationOptions = < TError = ErrorType, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number }, TContext >; request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, { timerId: number }, TContext > => { const mutationKey = ["stopTimer"]; 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>, { timerId: number } > = (props) => { const { timerId } = props ?? {}; return stopTimer(timerId, requestOptions); }; return { mutationFn, ...mutationOptions }; }; export type StopTimerMutationResult = NonNullable< Awaited> >; export type StopTimerMutationError = ErrorType; /** * @summary 타이머 μ’…λ£Œ */ export const useStopTimer = , TContext = unknown>( options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number }, TContext >; request?: SecondParameter; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { timerId: number }, TContext > => { return useMutation(getStopTimerMutationOptions(options), queryClient); }; /** * μ‹€ν–‰ 쀑인 νƒ€μ΄λ¨Έμ˜ μΌμ‹œμ •μ§€ / 재개λ₯Ό μ²˜λ¦¬ν•©λ‹ˆλ‹€.
* PAUSE: ν˜„μž¬ μ„Έμ…˜μ˜ paused_at 기둝, status β†’ PAUSED
* RESUME: μƒˆ μ„Έμ…˜ 생성, status β†’ RUNNING * @summary 타이머 μΌμ‹œμ •μ§€/재개 */ export const changeStatus = ( timerId: number, timerActionRequest: BodyType, options?: SecondParameter, signal?: AbortSignal, ) => { return customInstance( { url: `/api/v1/timers/${timerId}/status`, method: "PATCH", headers: { "Content-Type": "application/json" }, data: timerActionRequest, signal, }, options, ); }; export const getChangeStatusMutationOptions = < TError = ErrorType, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number; data: BodyType }, TContext >; request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, { timerId: number; data: BodyType }, TContext > => { const mutationKey = ["changeStatus"]; 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>, { timerId: number; data: BodyType } > = (props) => { const { timerId, data } = props ?? {}; return changeStatus(timerId, data, requestOptions); }; return { mutationFn, ...mutationOptions }; }; export type ChangeStatusMutationResult = NonNullable< Awaited> >; export type ChangeStatusMutationBody = BodyType; export type ChangeStatusMutationError = ErrorType; /** * @summary 타이머 μΌμ‹œμ •μ§€/재개 */ export const useChangeStatus = < TError = ErrorType, TContext = unknown, >( options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number; data: BodyType }, TContext >; request?: SecondParameter; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { timerId: number; data: BodyType }, TContext > => { return useMutation(getChangeStatusMutationOptions(options), queryClient); }; /** * μ‚¬μš©μžκ°€ μž…λ ₯ν•œ μ—°μž₯ μ‹œκ°„μ„ ν˜„μž¬ 타이머에 λ°˜μ˜ν•©λ‹ˆλ‹€. * μ—°μž₯ μ‹œκ°„(λΆ„)을 초둜 λ³€ν™˜ν•˜μ—¬ extended_seconds에 λˆ„μ  * RUNNING, PAUSED μƒνƒœ λͺ¨λ‘μ—μ„œ 호좜 κ°€λŠ₯ν•˜λ©°, 타이머 μƒνƒœ(status)λŠ” λ³€κ²½λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. * @summary 타이머 μ—°μž₯ */ export const extendTimer = ( timerId: number, timerExtendRequest: BodyType, options?: SecondParameter, signal?: AbortSignal, ) => { return customInstance( { url: `/api/v1/timers/${timerId}/extend`, method: "PATCH", headers: { "Content-Type": "application/json" }, data: timerExtendRequest, signal, }, options, ); }; export const getExtendTimerMutationOptions = < TError = ErrorType, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number; data: BodyType }, TContext >; request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, { timerId: number; data: BodyType }, TContext > => { const mutationKey = ["extendTimer"]; 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>, { timerId: number; data: BodyType } > = (props) => { const { timerId, data } = props ?? {}; return extendTimer(timerId, data, requestOptions); }; return { mutationFn, ...mutationOptions }; }; export type ExtendTimerMutationResult = NonNullable< Awaited> >; export type ExtendTimerMutationBody = BodyType; export type ExtendTimerMutationError = ErrorType; /** * @summary 타이머 μ—°μž₯ */ export const useExtendTimer = < TError = ErrorType, TContext = unknown, >( options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number; data: BodyType }, TContext >; request?: SecondParameter; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { timerId: number; data: BodyType }, TContext > => { return useMutation(getExtendTimerMutationOptions(options), queryClient); }; /** * μ˜ˆμƒ μ†Œμš” μ‹œκ°„μ΄ λͺ¨λ‘ κ²½κ³Όν•˜μ—¬ 타이머λ₯Ό μžλ™ μ’…λ£Œν•©λ‹ˆλ‹€. * μ’…λ£Œ μ‹œκ° 기둝, μ‹€μ œ μˆ˜ν–‰ μ‹œκ°„ 계산 (status β†’ COMPLETED) * ν•΄λ‹Ή λ‚ μ§œ TodoInstance μ™„λ£Œ 처리 및 타이머 μƒνƒœ μ΄ˆκΈ°ν™” * κ³„νš μ‹œκ°„κ³Ό μ‹€μ œ μˆ˜ν–‰ 기둝을 λΆ„μ„ν•œ AI ν”Όλ“œλ°± λ°˜ν™˜ * AI ν”Όλ“œλ°± 생성에 μ‹€νŒ¨ν•΄λ„ 타이머 μ™„λ£ŒλŠ” 정상 처리되며 aiFeedback은 null둜 λ°˜ν™˜ * @summary 타이머 μ‹œκ°„ μ™„λ£Œ */ export const completeTimer = ( timerId: number, options?: SecondParameter, signal?: AbortSignal, ) => { return customInstance( { url: `/api/v1/timers/${timerId}/complete`, method: "PATCH", signal }, options, ); }; export const getCompleteTimerMutationOptions = < TError = ErrorType, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number }, TContext >; request?: SecondParameter; }): UseMutationOptions< Awaited>, TError, { timerId: number }, TContext > => { const mutationKey = ["completeTimer"]; 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>, { timerId: number } > = (props) => { const { timerId } = props ?? {}; return completeTimer(timerId, requestOptions); }; return { mutationFn, ...mutationOptions }; }; export type CompleteTimerMutationResult = NonNullable< Awaited> >; export type CompleteTimerMutationError = ErrorType; /** * @summary 타이머 μ‹œκ°„ μ™„λ£Œ */ export const useCompleteTimer = < TError = ErrorType, TContext = unknown, >( options?: { mutation?: UseMutationOptions< Awaited>, TError, { timerId: number }, TContext >; request?: SecondParameter; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { timerId: number }, TContext > => { return useMutation(getCompleteTimerMutationOptions(options), queryClient); }; /** * λ‘œκ·ΈμΈν•œ μ‚¬μš©μžμ˜ ν˜„μž¬ μ‹€ν–‰ 쀑(RUNNING/PAUSED)인 타이머λ₯Ό 단건 μ‘°νšŒν•©λ‹ˆλ‹€. * ν•œ μ‚¬μš©μžλ‹Ή μ‹œμž‘ 이후 μ™„λ£Œ/μ’…λ£Œλ˜μ§€ μ•Šμ€ νƒ€μ΄λ¨ΈλŠ” μ΅œλŒ€ 1개만 μ‘΄μž¬ν•  수 μžˆμŠ΅λ‹ˆλ‹€. * μ‹€ν–‰ 쀑인 타이머가 μ—†μœΌλ©΄ data: null을 λ°˜ν™˜ν•©λ‹ˆλ‹€. * * μ‘λ‹΅μ˜ dateλŠ” 타이머가 κ·€μ†λ˜λŠ” λ‚ μ§œ(μ‚¬μš©μž μ‹œκ°„λŒ€ κΈ°μ€€ μ‹œμž‘μΌ)μž…λ‹ˆλ‹€. * 반볡 νˆ¬λ‘λŠ” μ—¬λŸ¬ λ‚ μ§œμ— 같은 todoId둜 λ…ΈμΆœλ˜λ―€λ‘œ, 싀행쀑 ν‘œμ‹œλŠ” todoIdκ°€ μ•„λ‹Œ (todoId, date) μ‘°ν•©μœΌλ‘œ ꡬ뢄해야 ν•©λ‹ˆλ‹€. * @summary ν˜„μž¬ μ‹€ν–‰ 쀑인 타이머 쑰회 */ export const getActiveTimer = ( options?: SecondParameter, signal?: AbortSignal, ) => { return customInstance( { url: `/api/v1/timers/active`, method: "GET", signal }, options, ); }; export const getGetActiveTimerQueryKey = () => { return [`/api/v1/timers/active`] as const; }; export const getGetActiveTimerQueryOptions = < TData = Awaited>, TError = ErrorType, >(options?: { query?: Partial< UseQueryOptions>, TError, TData> >; request?: SecondParameter; }) => { const { query: queryOptions, request: requestOptions } = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetActiveTimerQueryKey(); const queryFn: QueryFunction>> = ({ signal, }) => getActiveTimer(requestOptions, signal); return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< Awaited>, TError, TData > & { queryKey: DataTag }; }; export type GetActiveTimerQueryResult = NonNullable< Awaited> >; export type GetActiveTimerQueryError = ErrorType; export function useGetActiveTimer< TData = Awaited>, TError = ErrorType, >( options: { query: Partial< UseQueryOptions>, TError, TData> > & Pick< DefinedInitialDataOptions< Awaited>, TError, Awaited> >, "initialData" >; request?: SecondParameter; }, queryClient?: QueryClient, ): DefinedUseQueryResult & { queryKey: DataTag; }; export function useGetActiveTimer< TData = Awaited>, TError = ErrorType, >( options?: { query?: Partial< UseQueryOptions>, TError, TData> > & Pick< UndefinedInitialDataOptions< Awaited>, TError, Awaited> >, "initialData" >; request?: SecondParameter; }, queryClient?: QueryClient, ): UseQueryResult & { queryKey: DataTag; }; export function useGetActiveTimer< TData = Awaited>, TError = ErrorType, >( options?: { query?: Partial< UseQueryOptions>, TError, TData> >; request?: SecondParameter; }, queryClient?: QueryClient, ): UseQueryResult & { queryKey: DataTag; }; /** * @summary ν˜„μž¬ μ‹€ν–‰ 쀑인 타이머 쑰회 */ export function useGetActiveTimer< TData = Awaited>, TError = ErrorType, >( options?: { query?: Partial< UseQueryOptions>, TError, TData> >; request?: SecondParameter; }, queryClient?: QueryClient, ): UseQueryResult & { queryKey: DataTag; } { const queryOptions = getGetActiveTimerQueryOptions(options); const query = useQuery(queryOptions, queryClient) as UseQueryResult< TData, TError > & { queryKey: DataTag }; return withQueryKey(query, queryOptions.queryKey); }