/**
 * Generated by orval v8.3.0 🍺
 * Do not edit manually.
 * Mission Control 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 {
  BlockedTaskError,
  HTTPValidationError,
  LimitOffsetPageTypeVarCustomizedTaskCommentRead,
  LimitOffsetPageTypeVarCustomizedTaskRead,
  ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetParams,
  ListTasksApiV1BoardsBoardIdTasksGetParams,
  OkResponse,
  StreamTasksApiV1BoardsBoardIdTasksStreamGetParams,
  TaskCommentCreate,
  TaskCommentRead,
  TaskCreate,
  TaskRead,
  TaskUpdate,
} from ".././model";

import { customFetch } from "../../mutator";

type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];

/**
 * List board tasks with optional status and assignment filters.
 * @summary List Tasks
 */
export type listTasksApiV1BoardsBoardIdTasksGetResponse200 = {
  data: LimitOffsetPageTypeVarCustomizedTaskRead;
  status: 200;
};

export type listTasksApiV1BoardsBoardIdTasksGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type listTasksApiV1BoardsBoardIdTasksGetResponseSuccess =
  listTasksApiV1BoardsBoardIdTasksGetResponse200 & {
    headers: Headers;
  };
export type listTasksApiV1BoardsBoardIdTasksGetResponseError =
  listTasksApiV1BoardsBoardIdTasksGetResponse422 & {
    headers: Headers;
  };

export type listTasksApiV1BoardsBoardIdTasksGetResponse =
  | listTasksApiV1BoardsBoardIdTasksGetResponseSuccess
  | listTasksApiV1BoardsBoardIdTasksGetResponseError;

export const getListTasksApiV1BoardsBoardIdTasksGetUrl = (
  boardId: string,
  params?: ListTasksApiV1BoardsBoardIdTasksGetParams,
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? "null" : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1/boards/${boardId}/tasks?${stringifiedParams}`
    : `/api/v1/boards/${boardId}/tasks`;
};

export const listTasksApiV1BoardsBoardIdTasksGet = async (
  boardId: string,
  params?: ListTasksApiV1BoardsBoardIdTasksGetParams,
  options?: RequestInit,
): Promise<listTasksApiV1BoardsBoardIdTasksGetResponse> => {
  return customFetch<listTasksApiV1BoardsBoardIdTasksGetResponse>(
    getListTasksApiV1BoardsBoardIdTasksGetUrl(boardId, params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListTasksApiV1BoardsBoardIdTasksGetQueryKey = (
  boardId: string,
  params?: ListTasksApiV1BoardsBoardIdTasksGetParams,
) => {
  return [
    `/api/v1/boards/${boardId}/tasks`,
    ...(params ? [params] : []),
  ] as const;
};

export const getListTasksApiV1BoardsBoardIdTasksGetQueryOptions = <
  TData = Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: ListTasksApiV1BoardsBoardIdTasksGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getListTasksApiV1BoardsBoardIdTasksGetQueryKey(boardId, params);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>
  > = ({ signal }) =>
    listTasksApiV1BoardsBoardIdTasksGet(boardId, params, {
      signal,
      ...requestOptions,
    });

  return {
    queryKey,
    queryFn,
    enabled: !!boardId,
    ...queryOptions,
  } as UseQueryOptions<
    Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type ListTasksApiV1BoardsBoardIdTasksGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>
>;
export type ListTasksApiV1BoardsBoardIdTasksGetQueryError = HTTPValidationError;

export function useListTasksApiV1BoardsBoardIdTasksGet<
  TData = Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
  TError = HTTPValidationError,
>(
  boardId: string,
  params: undefined | ListTasksApiV1BoardsBoardIdTasksGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
          TError,
          Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListTasksApiV1BoardsBoardIdTasksGet<
  TData = Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: ListTasksApiV1BoardsBoardIdTasksGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
          TError,
          Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListTasksApiV1BoardsBoardIdTasksGet<
  TData = Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: ListTasksApiV1BoardsBoardIdTasksGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Tasks
 */

export function useListTasksApiV1BoardsBoardIdTasksGet<
  TData = Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: ListTasksApiV1BoardsBoardIdTasksGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listTasksApiV1BoardsBoardIdTasksGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getListTasksApiV1BoardsBoardIdTasksGetQueryOptions(
    boardId,
    params,
    options,
  );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Create a task and initialize dependency rows.
 * @summary Create Task
 */
export type createTaskApiV1BoardsBoardIdTasksPostResponse200 = {
  data: TaskRead;
  status: 200;
};

export type createTaskApiV1BoardsBoardIdTasksPostResponse409 = {
  data: BlockedTaskError;
  status: 409;
};

export type createTaskApiV1BoardsBoardIdTasksPostResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type createTaskApiV1BoardsBoardIdTasksPostResponseSuccess =
  createTaskApiV1BoardsBoardIdTasksPostResponse200 & {
    headers: Headers;
  };
export type createTaskApiV1BoardsBoardIdTasksPostResponseError = (
  | createTaskApiV1BoardsBoardIdTasksPostResponse409
  | createTaskApiV1BoardsBoardIdTasksPostResponse422
) & {
  headers: Headers;
};

export type createTaskApiV1BoardsBoardIdTasksPostResponse =
  | createTaskApiV1BoardsBoardIdTasksPostResponseSuccess
  | createTaskApiV1BoardsBoardIdTasksPostResponseError;

export const getCreateTaskApiV1BoardsBoardIdTasksPostUrl = (
  boardId: string,
) => {
  return `/api/v1/boards/${boardId}/tasks`;
};

export const createTaskApiV1BoardsBoardIdTasksPost = async (
  boardId: string,
  taskCreate: TaskCreate,
  options?: RequestInit,
): Promise<createTaskApiV1BoardsBoardIdTasksPostResponse> => {
  return customFetch<createTaskApiV1BoardsBoardIdTasksPostResponse>(
    getCreateTaskApiV1BoardsBoardIdTasksPostUrl(boardId),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(taskCreate),
    },
  );
};

export const getCreateTaskApiV1BoardsBoardIdTasksPostMutationOptions = <
  TError = BlockedTaskError | HTTPValidationError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof createTaskApiV1BoardsBoardIdTasksPost>>,
    TError,
    { boardId: string; data: TaskCreate },
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof createTaskApiV1BoardsBoardIdTasksPost>>,
  TError,
  { boardId: string; data: TaskCreate },
  TContext
> => {
  const mutationKey = ["createTaskApiV1BoardsBoardIdTasksPost"];
  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 createTaskApiV1BoardsBoardIdTasksPost>>,
    { boardId: string; data: TaskCreate }
  > = (props) => {
    const { boardId, data } = props ?? {};

    return createTaskApiV1BoardsBoardIdTasksPost(boardId, data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type CreateTaskApiV1BoardsBoardIdTasksPostMutationResult = NonNullable<
  Awaited<ReturnType<typeof createTaskApiV1BoardsBoardIdTasksPost>>
>;
export type CreateTaskApiV1BoardsBoardIdTasksPostMutationBody = TaskCreate;
export type CreateTaskApiV1BoardsBoardIdTasksPostMutationError =
  | BlockedTaskError
  | HTTPValidationError;

/**
 * @summary Create Task
 */
export const useCreateTaskApiV1BoardsBoardIdTasksPost = <
  TError = BlockedTaskError | HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof createTaskApiV1BoardsBoardIdTasksPost>>,
      TError,
      { boardId: string; data: TaskCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof createTaskApiV1BoardsBoardIdTasksPost>>,
  TError,
  { boardId: string; data: TaskCreate },
  TContext
> => {
  return useMutation(
    getCreateTaskApiV1BoardsBoardIdTasksPostMutationOptions(options),
    queryClient,
  );
};
/**
 * Stream task and task-comment events as SSE payloads.
 * @summary Stream Tasks
 */
export type streamTasksApiV1BoardsBoardIdTasksStreamGetResponse200 = {
  data: unknown;
  status: 200;
};

export type streamTasksApiV1BoardsBoardIdTasksStreamGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type streamTasksApiV1BoardsBoardIdTasksStreamGetResponseSuccess =
  streamTasksApiV1BoardsBoardIdTasksStreamGetResponse200 & {
    headers: Headers;
  };
export type streamTasksApiV1BoardsBoardIdTasksStreamGetResponseError =
  streamTasksApiV1BoardsBoardIdTasksStreamGetResponse422 & {
    headers: Headers;
  };

export type streamTasksApiV1BoardsBoardIdTasksStreamGetResponse =
  | streamTasksApiV1BoardsBoardIdTasksStreamGetResponseSuccess
  | streamTasksApiV1BoardsBoardIdTasksStreamGetResponseError;

export const getStreamTasksApiV1BoardsBoardIdTasksStreamGetUrl = (
  boardId: string,
  params?: StreamTasksApiV1BoardsBoardIdTasksStreamGetParams,
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? "null" : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1/boards/${boardId}/tasks/stream?${stringifiedParams}`
    : `/api/v1/boards/${boardId}/tasks/stream`;
};

export const streamTasksApiV1BoardsBoardIdTasksStreamGet = async (
  boardId: string,
  params?: StreamTasksApiV1BoardsBoardIdTasksStreamGetParams,
  options?: RequestInit,
): Promise<streamTasksApiV1BoardsBoardIdTasksStreamGetResponse> => {
  return customFetch<streamTasksApiV1BoardsBoardIdTasksStreamGetResponse>(
    getStreamTasksApiV1BoardsBoardIdTasksStreamGetUrl(boardId, params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getStreamTasksApiV1BoardsBoardIdTasksStreamGetQueryKey = (
  boardId: string,
  params?: StreamTasksApiV1BoardsBoardIdTasksStreamGetParams,
) => {
  return [
    `/api/v1/boards/${boardId}/tasks/stream`,
    ...(params ? [params] : []),
  ] as const;
};

export const getStreamTasksApiV1BoardsBoardIdTasksStreamGetQueryOptions = <
  TData = Awaited<
    ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: StreamTasksApiV1BoardsBoardIdTasksStreamGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getStreamTasksApiV1BoardsBoardIdTasksStreamGetQueryKey(boardId, params);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>>
  > = ({ signal }) =>
    streamTasksApiV1BoardsBoardIdTasksStreamGet(boardId, params, {
      signal,
      ...requestOptions,
    });

  return {
    queryKey,
    queryFn,
    enabled: !!boardId,
    ...queryOptions,
  } as UseQueryOptions<
    Awaited<ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type StreamTasksApiV1BoardsBoardIdTasksStreamGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>>
  >;
export type StreamTasksApiV1BoardsBoardIdTasksStreamGetQueryError =
  HTTPValidationError;

export function useStreamTasksApiV1BoardsBoardIdTasksStreamGet<
  TData = Awaited<
    ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params: undefined | StreamTasksApiV1BoardsBoardIdTasksStreamGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useStreamTasksApiV1BoardsBoardIdTasksStreamGet<
  TData = Awaited<
    ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: StreamTasksApiV1BoardsBoardIdTasksStreamGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useStreamTasksApiV1BoardsBoardIdTasksStreamGet<
  TData = Awaited<
    ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: StreamTasksApiV1BoardsBoardIdTasksStreamGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Stream Tasks
 */

export function useStreamTasksApiV1BoardsBoardIdTasksStreamGet<
  TData = Awaited<
    ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: StreamTasksApiV1BoardsBoardIdTasksStreamGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof streamTasksApiV1BoardsBoardIdTasksStreamGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getStreamTasksApiV1BoardsBoardIdTasksStreamGetQueryOptions(
      boardId,
      params,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Delete a task and related records.
 * @summary Delete Task
 */
export type deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponse200 = {
  data: OkResponse;
  status: 200;
};

export type deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponseSuccess =
  deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponse200 & {
    headers: Headers;
  };
export type deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponseError =
  deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponse422 & {
    headers: Headers;
  };

export type deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponse =
  | deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponseSuccess
  | deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponseError;

export const getDeleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteUrl = (
  boardId: string,
  taskId: string,
) => {
  return `/api/v1/boards/${boardId}/tasks/${taskId}`;
};

export const deleteTaskApiV1BoardsBoardIdTasksTaskIdDelete = async (
  boardId: string,
  taskId: string,
  options?: RequestInit,
): Promise<deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponse> => {
  return customFetch<deleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteResponse>(
    getDeleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteUrl(boardId, taskId),
    {
      ...options,
      method: "DELETE",
    },
  );
};

export const getDeleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteMutationOptions = <
  TError = HTTPValidationError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof deleteTaskApiV1BoardsBoardIdTasksTaskIdDelete>>,
    TError,
    { boardId: string; taskId: string },
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof deleteTaskApiV1BoardsBoardIdTasksTaskIdDelete>>,
  TError,
  { boardId: string; taskId: string },
  TContext
> => {
  const mutationKey = ["deleteTaskApiV1BoardsBoardIdTasksTaskIdDelete"];
  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 deleteTaskApiV1BoardsBoardIdTasksTaskIdDelete>>,
    { boardId: string; taskId: string }
  > = (props) => {
    const { boardId, taskId } = props ?? {};

    return deleteTaskApiV1BoardsBoardIdTasksTaskIdDelete(
      boardId,
      taskId,
      requestOptions,
    );
  };

  return { mutationFn, ...mutationOptions };
};

export type DeleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof deleteTaskApiV1BoardsBoardIdTasksTaskIdDelete>>
  >;

export type DeleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteMutationError =
  HTTPValidationError;

/**
 * @summary Delete Task
 */
export const useDeleteTaskApiV1BoardsBoardIdTasksTaskIdDelete = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof deleteTaskApiV1BoardsBoardIdTasksTaskIdDelete>>,
      TError,
      { boardId: string; taskId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof deleteTaskApiV1BoardsBoardIdTasksTaskIdDelete>>,
  TError,
  { boardId: string; taskId: string },
  TContext
> => {
  return useMutation(
    getDeleteTaskApiV1BoardsBoardIdTasksTaskIdDeleteMutationOptions(options),
    queryClient,
  );
};
/**
 * Update task status, assignment, comment, and dependency state.
 * @summary Update Task
 */
export type updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponse200 = {
  data: TaskRead;
  status: 200;
};

export type updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponse409 = {
  data: BlockedTaskError;
  status: 409;
};

export type updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponseSuccess =
  updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponse200 & {
    headers: Headers;
  };
export type updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponseError = (
  | updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponse409
  | updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponse422
) & {
  headers: Headers;
};

export type updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponse =
  | updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponseSuccess
  | updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponseError;

export const getUpdateTaskApiV1BoardsBoardIdTasksTaskIdPatchUrl = (
  boardId: string,
  taskId: string,
) => {
  return `/api/v1/boards/${boardId}/tasks/${taskId}`;
};

export const updateTaskApiV1BoardsBoardIdTasksTaskIdPatch = async (
  boardId: string,
  taskId: string,
  taskUpdate: TaskUpdate,
  options?: RequestInit,
): Promise<updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponse> => {
  return customFetch<updateTaskApiV1BoardsBoardIdTasksTaskIdPatchResponse>(
    getUpdateTaskApiV1BoardsBoardIdTasksTaskIdPatchUrl(boardId, taskId),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(taskUpdate),
    },
  );
};

export const getUpdateTaskApiV1BoardsBoardIdTasksTaskIdPatchMutationOptions = <
  TError = BlockedTaskError | HTTPValidationError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof updateTaskApiV1BoardsBoardIdTasksTaskIdPatch>>,
    TError,
    { boardId: string; taskId: string; data: TaskUpdate },
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof updateTaskApiV1BoardsBoardIdTasksTaskIdPatch>>,
  TError,
  { boardId: string; taskId: string; data: TaskUpdate },
  TContext
> => {
  const mutationKey = ["updateTaskApiV1BoardsBoardIdTasksTaskIdPatch"];
  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 updateTaskApiV1BoardsBoardIdTasksTaskIdPatch>>,
    { boardId: string; taskId: string; data: TaskUpdate }
  > = (props) => {
    const { boardId, taskId, data } = props ?? {};

    return updateTaskApiV1BoardsBoardIdTasksTaskIdPatch(
      boardId,
      taskId,
      data,
      requestOptions,
    );
  };

  return { mutationFn, ...mutationOptions };
};

export type UpdateTaskApiV1BoardsBoardIdTasksTaskIdPatchMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof updateTaskApiV1BoardsBoardIdTasksTaskIdPatch>>
  >;
export type UpdateTaskApiV1BoardsBoardIdTasksTaskIdPatchMutationBody =
  TaskUpdate;
export type UpdateTaskApiV1BoardsBoardIdTasksTaskIdPatchMutationError =
  | BlockedTaskError
  | HTTPValidationError;

/**
 * @summary Update Task
 */
export const useUpdateTaskApiV1BoardsBoardIdTasksTaskIdPatch = <
  TError = BlockedTaskError | HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof updateTaskApiV1BoardsBoardIdTasksTaskIdPatch>>,
      TError,
      { boardId: string; taskId: string; data: TaskUpdate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof updateTaskApiV1BoardsBoardIdTasksTaskIdPatch>>,
  TError,
  { boardId: string; taskId: string; data: TaskUpdate },
  TContext
> => {
  return useMutation(
    getUpdateTaskApiV1BoardsBoardIdTasksTaskIdPatchMutationOptions(options),
    queryClient,
  );
};
/**
 * List comments for a task in chronological order.
 * @summary List Task Comments
 */
export type listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponse200 =
  {
    data: LimitOffsetPageTypeVarCustomizedTaskCommentRead;
    status: 200;
  };

export type listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponseSuccess =
  listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponse200 & {
    headers: Headers;
  };
export type listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponseError =
  listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponse422 & {
    headers: Headers;
  };

export type listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponse =
  | listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponseSuccess
  | listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponseError;

export const getListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetUrl = (
  boardId: string,
  taskId: string,
  params?: ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetParams,
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? "null" : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1/boards/${boardId}/tasks/${taskId}/comments?${stringifiedParams}`
    : `/api/v1/boards/${boardId}/tasks/${taskId}/comments`;
};

export const listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet = async (
  boardId: string,
  taskId: string,
  params?: ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetParams,
  options?: RequestInit,
): Promise<listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponse> => {
  return customFetch<listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetResponse>(
    getListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetUrl(
      boardId,
      taskId,
      params,
    ),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetQueryKey =
  (
    boardId: string,
    taskId: string,
    params?: ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetParams,
  ) => {
    return [
      `/api/v1/boards/${boardId}/tasks/${taskId}/comments`,
      ...(params ? [params] : []),
    ] as const;
  };

export const getListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<
        typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
      >
    >,
    TError = HTTPValidationError,
  >(
    boardId: string,
    taskId: string,
    params?: ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetParams,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetQueryKey(
        boardId,
        taskId,
        params,
      );

    const queryFn: QueryFunction<
      Awaited<
        ReturnType<
          typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
        >
      >
    > = ({ signal }) =>
      listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet(
        boardId,
        taskId,
        params,
        { signal, ...requestOptions },
      );

    return {
      queryKey,
      queryFn,
      enabled: !!(boardId && taskId),
      ...queryOptions,
    } as UseQueryOptions<
      Awaited<
        ReturnType<
          typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
        >
      >,
      TError,
      TData
    > & { queryKey: DataTag<QueryKey, TData, TError> };
  };

export type ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
      >
    >
  >;
export type ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetQueryError =
  HTTPValidationError;

export function useListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet<
  TData = Awaited<
    ReturnType<typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  taskId: string,
  params:
    | undefined
    | ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet<
  TData = Awaited<
    ReturnType<typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  taskId: string,
  params?: ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet<
  TData = Awaited<
    ReturnType<typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  taskId: string,
  params?: ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Task Comments
 */

export function useListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet<
  TData = Awaited<
    ReturnType<typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  taskId: string,
  params?: ListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof listTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getListTaskCommentsApiV1BoardsBoardIdTasksTaskIdCommentsGetQueryOptions(
      boardId,
      taskId,
      params,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Create a task comment and notify relevant agents.
 * @summary Create Task Comment
 */
export type createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponse200 =
  {
    data: TaskCommentRead;
    status: 200;
  };

export type createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponseSuccess =
  createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponse200 & {
    headers: Headers;
  };
export type createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponseError =
  createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponse422 & {
    headers: Headers;
  };

export type createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponse =
  | createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponseSuccess
  | createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponseError;

export const getCreateTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostUrl =
  (boardId: string, taskId: string) => {
    return `/api/v1/boards/${boardId}/tasks/${taskId}/comments`;
  };

export const createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost =
  async (
    boardId: string,
    taskId: string,
    taskCommentCreate: TaskCommentCreate,
    options?: RequestInit,
  ): Promise<createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponse> => {
    return customFetch<createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostResponse>(
      getCreateTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostUrl(
        boardId,
        taskId,
      ),
      {
        ...options,
        method: "POST",
        headers: { "Content-Type": "application/json", ...options?.headers },
        body: JSON.stringify(taskCommentCreate),
      },
    );
  };

export const getCreateTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost
        >
      >,
      TError,
      { boardId: string; taskId: string; data: TaskCommentCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<
        typeof createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost
      >
    >,
    TError,
    { boardId: string; taskId: string; data: TaskCommentCreate },
    TContext
  > => {
    const mutationKey = [
      "createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost",
    ];
    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 createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost
        >
      >,
      { boardId: string; taskId: string; data: TaskCommentCreate }
    > = (props) => {
      const { boardId, taskId, data } = props ?? {};

      return createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost(
        boardId,
        taskId,
        data,
        requestOptions,
      );
    };

    return { mutationFn, ...mutationOptions };
  };

export type CreateTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost
      >
    >
  >;
export type CreateTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostMutationBody =
  TaskCommentCreate;
export type CreateTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostMutationError =
  HTTPValidationError;

/**
 * @summary Create Task Comment
 */
export const useCreateTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost
        >
      >,
      TError,
      { boardId: string; taskId: string; data: TaskCommentCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<
      typeof createTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPost
    >
  >,
  TError,
  { boardId: string; taskId: string; data: TaskCommentCreate },
  TContext
> => {
  return useMutation(
    getCreateTaskCommentApiV1BoardsBoardIdTasksTaskIdCommentsPostMutationOptions(
      options,
    ),
    queryClient,
  );
};
