/**
 * 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 {
  HTTPValidationError,
  InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams,
  ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  MarketplaceSkillActionResponse,
  MarketplaceSkillCardRead,
  MarketplaceSkillCreate,
  MarketplaceSkillRead,
  OkResponse,
  SkillPackCreate,
  SkillPackRead,
  SkillPackSyncResponse,
  UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams,
} from ".././model";

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

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

/**
 * List marketplace cards for an org and annotate install state for a gateway.
 * @summary List Marketplace Skills
 */
export type listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse200 = {
  data: MarketplaceSkillCardRead[];
  status: 200;
};

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

export type listMarketplaceSkillsApiV1SkillsMarketplaceGetResponseSuccess =
  listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse200 & {
    headers: Headers;
  };
export type listMarketplaceSkillsApiV1SkillsMarketplaceGetResponseError =
  listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse422 & {
    headers: Headers;
  };

export type listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse =
  | listMarketplaceSkillsApiV1SkillsMarketplaceGetResponseSuccess
  | listMarketplaceSkillsApiV1SkillsMarketplaceGetResponseError;

export const getListMarketplaceSkillsApiV1SkillsMarketplaceGetUrl = (
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
) => {
  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/skills/marketplace?${stringifiedParams}`
    : `/api/v1/skills/marketplace`;
};

export const listMarketplaceSkillsApiV1SkillsMarketplaceGet = async (
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options?: RequestInit,
): Promise<listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse> => {
  return customFetch<listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse>(
    getListMarketplaceSkillsApiV1SkillsMarketplaceGetUrl(params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListMarketplaceSkillsApiV1SkillsMarketplaceGetQueryKey = (
  params?: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
) => {
  return [`/api/v1/skills/marketplace`, ...(params ? [params] : [])] as const;
};

export const getListMarketplaceSkillsApiV1SkillsMarketplaceGetQueryOptions = <
  TData = Awaited<
    ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
  >,
  TError = HTTPValidationError,
>(
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getListMarketplaceSkillsApiV1SkillsMarketplaceGetQueryKey(params);

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

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

export type ListMarketplaceSkillsApiV1SkillsMarketplaceGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>>
  >;
export type ListMarketplaceSkillsApiV1SkillsMarketplaceGetQueryError =
  HTTPValidationError;

export function useListMarketplaceSkillsApiV1SkillsMarketplaceGet<
  TData = Awaited<
    ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
  >,
  TError = HTTPValidationError,
>(
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListMarketplaceSkillsApiV1SkillsMarketplaceGet<
  TData = Awaited<
    ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
  >,
  TError = HTTPValidationError,
>(
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListMarketplaceSkillsApiV1SkillsMarketplaceGet<
  TData = Awaited<
    ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
  >,
  TError = HTTPValidationError,
>(
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Marketplace Skills
 */

export function useListMarketplaceSkillsApiV1SkillsMarketplaceGet<
  TData = Awaited<
    ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
  >,
  TError = HTTPValidationError,
>(
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getListMarketplaceSkillsApiV1SkillsMarketplaceGetQueryOptions(
      params,
      options,
    );

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

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

/**
 * Register or update a direct marketplace skill URL in the catalog.
 * @summary Create Marketplace Skill
 */
export type createMarketplaceSkillApiV1SkillsMarketplacePostResponse200 = {
  data: MarketplaceSkillRead;
  status: 200;
};

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

export type createMarketplaceSkillApiV1SkillsMarketplacePostResponseSuccess =
  createMarketplaceSkillApiV1SkillsMarketplacePostResponse200 & {
    headers: Headers;
  };
export type createMarketplaceSkillApiV1SkillsMarketplacePostResponseError =
  createMarketplaceSkillApiV1SkillsMarketplacePostResponse422 & {
    headers: Headers;
  };

export type createMarketplaceSkillApiV1SkillsMarketplacePostResponse =
  | createMarketplaceSkillApiV1SkillsMarketplacePostResponseSuccess
  | createMarketplaceSkillApiV1SkillsMarketplacePostResponseError;

export const getCreateMarketplaceSkillApiV1SkillsMarketplacePostUrl = () => {
  return `/api/v1/skills/marketplace`;
};

export const createMarketplaceSkillApiV1SkillsMarketplacePost = async (
  marketplaceSkillCreate: MarketplaceSkillCreate,
  options?: RequestInit,
): Promise<createMarketplaceSkillApiV1SkillsMarketplacePostResponse> => {
  return customFetch<createMarketplaceSkillApiV1SkillsMarketplacePostResponse>(
    getCreateMarketplaceSkillApiV1SkillsMarketplacePostUrl(),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(marketplaceSkillCreate),
    },
  );
};

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

      return createMarketplaceSkillApiV1SkillsMarketplacePost(
        data,
        requestOptions,
      );
    };

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

export type CreateMarketplaceSkillApiV1SkillsMarketplacePostMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof createMarketplaceSkillApiV1SkillsMarketplacePost>>
  >;
export type CreateMarketplaceSkillApiV1SkillsMarketplacePostMutationBody =
  MarketplaceSkillCreate;
export type CreateMarketplaceSkillApiV1SkillsMarketplacePostMutationError =
  HTTPValidationError;

/**
 * @summary Create Marketplace Skill
 */
export const useCreateMarketplaceSkillApiV1SkillsMarketplacePost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof createMarketplaceSkillApiV1SkillsMarketplacePost>
      >,
      TError,
      { data: MarketplaceSkillCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof createMarketplaceSkillApiV1SkillsMarketplacePost>>,
  TError,
  { data: MarketplaceSkillCreate },
  TContext
> => {
  return useMutation(
    getCreateMarketplaceSkillApiV1SkillsMarketplacePostMutationOptions(options),
    queryClient,
  );
};
/**
 * Delete a marketplace catalog entry and any install records that reference it.
 * @summary Delete Marketplace Skill
 */
export type deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse200 =
  {
    data: OkResponse;
    status: 200;
  };

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

export type deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponseSuccess =
  deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse200 & {
    headers: Headers;
  };
export type deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponseError =
  deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse422 & {
    headers: Headers;
  };

export type deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse =
  | deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponseSuccess
  | deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponseError;

export const getDeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteUrl = (
  skillId: string,
) => {
  return `/api/v1/skills/marketplace/${skillId}`;
};

export const deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete = async (
  skillId: string,
  options?: RequestInit,
): Promise<deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse> => {
  return customFetch<deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse>(
    getDeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteUrl(skillId),
    {
      ...options,
      method: "DELETE",
    },
  );
};

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

      return deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete(
        skillId,
        requestOptions,
      );
    };

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

export type DeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete
      >
    >
  >;

export type DeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteMutationError =
  HTTPValidationError;

/**
 * @summary Delete Marketplace Skill
 */
export const useDeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete
        >
      >,
      TError,
      { skillId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<typeof deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete>
  >,
  TError,
  { skillId: string },
  TContext
> => {
  return useMutation(
    getDeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteMutationOptions(
      options,
    ),
    queryClient,
  );
};
/**
 * Install a marketplace skill by dispatching instructions to the gateway agent.
 * @summary Install Marketplace Skill
 */
export type installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse200 =
  {
    data: MarketplaceSkillActionResponse;
    status: 200;
  };

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

export type installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponseSuccess =
  installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse200 & {
    headers: Headers;
  };
export type installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponseError =
  installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse422 & {
    headers: Headers;
  };

export type installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse =

    | installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponseSuccess
    | installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponseError;

export const getInstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostUrl =
  (
    skillId: string,
    params: InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams,
  ) => {
    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/skills/marketplace/${skillId}/install?${stringifiedParams}`
      : `/api/v1/skills/marketplace/${skillId}/install`;
  };

export const installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost =
  async (
    skillId: string,
    params: InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams,
    options?: RequestInit,
  ): Promise<installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse> => {
    return customFetch<installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse>(
      getInstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostUrl(
        skillId,
        params,
      ),
      {
        ...options,
        method: "POST",
      },
    );
  };

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

      return installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost(
        skillId,
        params,
        requestOptions,
      );
    };

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

export type InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost
      >
    >
  >;

export type InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostMutationError =
  HTTPValidationError;

/**
 * @summary Install Marketplace Skill
 */
export const useInstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost =
  <TError = HTTPValidationError, TContext = unknown>(
    options?: {
      mutation?: UseMutationOptions<
        Awaited<
          ReturnType<
            typeof installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost
          >
        >,
        TError,
        {
          skillId: string;
          params: InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams;
        },
        TContext
      >;
      request?: SecondParameter<typeof customFetch>;
    },
    queryClient?: QueryClient,
  ): UseMutationResult<
    Awaited<
      ReturnType<
        typeof installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost
      >
    >,
    TError,
    {
      skillId: string;
      params: InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams;
    },
    TContext
  > => {
    return useMutation(
      getInstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostMutationOptions(
        options,
      ),
      queryClient,
    );
  };
/**
 * Uninstall a marketplace skill by dispatching instructions to the gateway agent.
 * @summary Uninstall Marketplace Skill
 */
export type uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse200 =
  {
    data: MarketplaceSkillActionResponse;
    status: 200;
  };

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

export type uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponseSuccess =
  uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse200 & {
    headers: Headers;
  };
export type uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponseError =
  uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse422 & {
    headers: Headers;
  };

export type uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse =

    | uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponseSuccess
    | uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponseError;

export const getUninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostUrl =
  (
    skillId: string,
    params: UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams,
  ) => {
    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/skills/marketplace/${skillId}/uninstall?${stringifiedParams}`
      : `/api/v1/skills/marketplace/${skillId}/uninstall`;
  };

export const uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost =
  async (
    skillId: string,
    params: UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams,
    options?: RequestInit,
  ): Promise<uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse> => {
    return customFetch<uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse>(
      getUninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostUrl(
        skillId,
        params,
      ),
      {
        ...options,
        method: "POST",
      },
    );
  };

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

      return uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost(
        skillId,
        params,
        requestOptions,
      );
    };

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

export type UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost
      >
    >
  >;

export type UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostMutationError =
  HTTPValidationError;

/**
 * @summary Uninstall Marketplace Skill
 */
export const useUninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost =
  <TError = HTTPValidationError, TContext = unknown>(
    options?: {
      mutation?: UseMutationOptions<
        Awaited<
          ReturnType<
            typeof uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost
          >
        >,
        TError,
        {
          skillId: string;
          params: UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams;
        },
        TContext
      >;
      request?: SecondParameter<typeof customFetch>;
    },
    queryClient?: QueryClient,
  ): UseMutationResult<
    Awaited<
      ReturnType<
        typeof uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost
      >
    >,
    TError,
    {
      skillId: string;
      params: UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams;
    },
    TContext
  > => {
    return useMutation(
      getUninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostMutationOptions(
        options,
      ),
      queryClient,
    );
  };
/**
 * List skill packs configured for the organization.
 * @summary List Skill Packs
 */
export type listSkillPacksApiV1SkillsPacksGetResponse200 = {
  data: SkillPackRead[];
  status: 200;
};

export type listSkillPacksApiV1SkillsPacksGetResponseSuccess =
  listSkillPacksApiV1SkillsPacksGetResponse200 & {
    headers: Headers;
  };
export type listSkillPacksApiV1SkillsPacksGetResponse =
  listSkillPacksApiV1SkillsPacksGetResponseSuccess;

export const getListSkillPacksApiV1SkillsPacksGetUrl = () => {
  return `/api/v1/skills/packs`;
};

export const listSkillPacksApiV1SkillsPacksGet = async (
  options?: RequestInit,
): Promise<listSkillPacksApiV1SkillsPacksGetResponse> => {
  return customFetch<listSkillPacksApiV1SkillsPacksGetResponse>(
    getListSkillPacksApiV1SkillsPacksGetUrl(),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListSkillPacksApiV1SkillsPacksGetQueryKey = () => {
  return [`/api/v1/skills/packs`] as const;
};

export const getListSkillPacksApiV1SkillsPacksGetQueryOptions = <
  TData = Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
  TError = unknown,
>(options?: {
  query?: Partial<
    UseQueryOptions<
      Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
      TError,
      TData
    >
  >;
  request?: SecondParameter<typeof customFetch>;
}) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ?? getListSkillPacksApiV1SkillsPacksGetQueryKey();

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

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

export type ListSkillPacksApiV1SkillsPacksGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>
>;
export type ListSkillPacksApiV1SkillsPacksGetQueryError = unknown;

export function useListSkillPacksApiV1SkillsPacksGet<
  TData = Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
  TError = unknown,
>(
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
          TError,
          Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListSkillPacksApiV1SkillsPacksGet<
  TData = Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
          TError,
          Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListSkillPacksApiV1SkillsPacksGet<
  TData = Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Skill Packs
 */

export function useListSkillPacksApiV1SkillsPacksGet<
  TData = Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listSkillPacksApiV1SkillsPacksGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getListSkillPacksApiV1SkillsPacksGetQueryOptions(options);

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

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

/**
 * Register a new skill pack source URL.
 * @summary Create Skill Pack
 */
export type createSkillPackApiV1SkillsPacksPostResponse200 = {
  data: SkillPackRead;
  status: 200;
};

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

export type createSkillPackApiV1SkillsPacksPostResponseSuccess =
  createSkillPackApiV1SkillsPacksPostResponse200 & {
    headers: Headers;
  };
export type createSkillPackApiV1SkillsPacksPostResponseError =
  createSkillPackApiV1SkillsPacksPostResponse422 & {
    headers: Headers;
  };

export type createSkillPackApiV1SkillsPacksPostResponse =
  | createSkillPackApiV1SkillsPacksPostResponseSuccess
  | createSkillPackApiV1SkillsPacksPostResponseError;

export const getCreateSkillPackApiV1SkillsPacksPostUrl = () => {
  return `/api/v1/skills/packs`;
};

export const createSkillPackApiV1SkillsPacksPost = async (
  skillPackCreate: SkillPackCreate,
  options?: RequestInit,
): Promise<createSkillPackApiV1SkillsPacksPostResponse> => {
  return customFetch<createSkillPackApiV1SkillsPacksPostResponse>(
    getCreateSkillPackApiV1SkillsPacksPostUrl(),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(skillPackCreate),
    },
  );
};

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

    return createSkillPackApiV1SkillsPacksPost(data, requestOptions);
  };

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

export type CreateSkillPackApiV1SkillsPacksPostMutationResult = NonNullable<
  Awaited<ReturnType<typeof createSkillPackApiV1SkillsPacksPost>>
>;
export type CreateSkillPackApiV1SkillsPacksPostMutationBody = SkillPackCreate;
export type CreateSkillPackApiV1SkillsPacksPostMutationError =
  HTTPValidationError;

/**
 * @summary Create Skill Pack
 */
export const useCreateSkillPackApiV1SkillsPacksPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof createSkillPackApiV1SkillsPacksPost>>,
      TError,
      { data: SkillPackCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof createSkillPackApiV1SkillsPacksPost>>,
  TError,
  { data: SkillPackCreate },
  TContext
> => {
  return useMutation(
    getCreateSkillPackApiV1SkillsPacksPostMutationOptions(options),
    queryClient,
  );
};
/**
 * Get one skill pack by ID.
 * @summary Get Skill Pack
 */
export type getSkillPackApiV1SkillsPacksPackIdGetResponse200 = {
  data: SkillPackRead;
  status: 200;
};

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

export type getSkillPackApiV1SkillsPacksPackIdGetResponseSuccess =
  getSkillPackApiV1SkillsPacksPackIdGetResponse200 & {
    headers: Headers;
  };
export type getSkillPackApiV1SkillsPacksPackIdGetResponseError =
  getSkillPackApiV1SkillsPacksPackIdGetResponse422 & {
    headers: Headers;
  };

export type getSkillPackApiV1SkillsPacksPackIdGetResponse =
  | getSkillPackApiV1SkillsPacksPackIdGetResponseSuccess
  | getSkillPackApiV1SkillsPacksPackIdGetResponseError;

export const getGetSkillPackApiV1SkillsPacksPackIdGetUrl = (packId: string) => {
  return `/api/v1/skills/packs/${packId}`;
};

export const getSkillPackApiV1SkillsPacksPackIdGet = async (
  packId: string,
  options?: RequestInit,
): Promise<getSkillPackApiV1SkillsPacksPackIdGetResponse> => {
  return customFetch<getSkillPackApiV1SkillsPacksPackIdGetResponse>(
    getGetSkillPackApiV1SkillsPacksPackIdGetUrl(packId),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetSkillPackApiV1SkillsPacksPackIdGetQueryKey = (
  packId: string,
) => {
  return [`/api/v1/skills/packs/${packId}`] as const;
};

export const getGetSkillPackApiV1SkillsPacksPackIdGetQueryOptions = <
  TData = Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
  TError = HTTPValidationError,
>(
  packId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getGetSkillPackApiV1SkillsPacksPackIdGetQueryKey(packId);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>
  > = ({ signal }) =>
    getSkillPackApiV1SkillsPacksPackIdGet(packId, {
      signal,
      ...requestOptions,
    });

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

export type GetSkillPackApiV1SkillsPacksPackIdGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>
>;
export type GetSkillPackApiV1SkillsPacksPackIdGetQueryError =
  HTTPValidationError;

export function useGetSkillPackApiV1SkillsPacksPackIdGet<
  TData = Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
  TError = HTTPValidationError,
>(
  packId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
          TError,
          Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetSkillPackApiV1SkillsPacksPackIdGet<
  TData = Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
  TError = HTTPValidationError,
>(
  packId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
          TError,
          Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetSkillPackApiV1SkillsPacksPackIdGet<
  TData = Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
  TError = HTTPValidationError,
>(
  packId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Skill Pack
 */

export function useGetSkillPackApiV1SkillsPacksPackIdGet<
  TData = Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
  TError = HTTPValidationError,
>(
  packId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getSkillPackApiV1SkillsPacksPackIdGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getGetSkillPackApiV1SkillsPacksPackIdGetQueryOptions(
    packId,
    options,
  );

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

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

/**
 * Update a skill pack URL and metadata.
 * @summary Update Skill Pack
 */
export type updateSkillPackApiV1SkillsPacksPackIdPatchResponse200 = {
  data: SkillPackRead;
  status: 200;
};

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

export type updateSkillPackApiV1SkillsPacksPackIdPatchResponseSuccess =
  updateSkillPackApiV1SkillsPacksPackIdPatchResponse200 & {
    headers: Headers;
  };
export type updateSkillPackApiV1SkillsPacksPackIdPatchResponseError =
  updateSkillPackApiV1SkillsPacksPackIdPatchResponse422 & {
    headers: Headers;
  };

export type updateSkillPackApiV1SkillsPacksPackIdPatchResponse =
  | updateSkillPackApiV1SkillsPacksPackIdPatchResponseSuccess
  | updateSkillPackApiV1SkillsPacksPackIdPatchResponseError;

export const getUpdateSkillPackApiV1SkillsPacksPackIdPatchUrl = (
  packId: string,
) => {
  return `/api/v1/skills/packs/${packId}`;
};

export const updateSkillPackApiV1SkillsPacksPackIdPatch = async (
  packId: string,
  skillPackCreate: SkillPackCreate,
  options?: RequestInit,
): Promise<updateSkillPackApiV1SkillsPacksPackIdPatchResponse> => {
  return customFetch<updateSkillPackApiV1SkillsPacksPackIdPatchResponse>(
    getUpdateSkillPackApiV1SkillsPacksPackIdPatchUrl(packId),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(skillPackCreate),
    },
  );
};

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

    return updateSkillPackApiV1SkillsPacksPackIdPatch(
      packId,
      data,
      requestOptions,
    );
  };

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

export type UpdateSkillPackApiV1SkillsPacksPackIdPatchMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof updateSkillPackApiV1SkillsPacksPackIdPatch>>
  >;
export type UpdateSkillPackApiV1SkillsPacksPackIdPatchMutationBody =
  SkillPackCreate;
export type UpdateSkillPackApiV1SkillsPacksPackIdPatchMutationError =
  HTTPValidationError;

/**
 * @summary Update Skill Pack
 */
export const useUpdateSkillPackApiV1SkillsPacksPackIdPatch = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof updateSkillPackApiV1SkillsPacksPackIdPatch>>,
      TError,
      { packId: string; data: SkillPackCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof updateSkillPackApiV1SkillsPacksPackIdPatch>>,
  TError,
  { packId: string; data: SkillPackCreate },
  TContext
> => {
  return useMutation(
    getUpdateSkillPackApiV1SkillsPacksPackIdPatchMutationOptions(options),
    queryClient,
  );
};
/**
 * Delete one pack source from the organization.
 * @summary Delete Skill Pack
 */
export type deleteSkillPackApiV1SkillsPacksPackIdDeleteResponse200 = {
  data: OkResponse;
  status: 200;
};

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

export type deleteSkillPackApiV1SkillsPacksPackIdDeleteResponseSuccess =
  deleteSkillPackApiV1SkillsPacksPackIdDeleteResponse200 & {
    headers: Headers;
  };
export type deleteSkillPackApiV1SkillsPacksPackIdDeleteResponseError =
  deleteSkillPackApiV1SkillsPacksPackIdDeleteResponse422 & {
    headers: Headers;
  };

export type deleteSkillPackApiV1SkillsPacksPackIdDeleteResponse =
  | deleteSkillPackApiV1SkillsPacksPackIdDeleteResponseSuccess
  | deleteSkillPackApiV1SkillsPacksPackIdDeleteResponseError;

export const getDeleteSkillPackApiV1SkillsPacksPackIdDeleteUrl = (
  packId: string,
) => {
  return `/api/v1/skills/packs/${packId}`;
};

export const deleteSkillPackApiV1SkillsPacksPackIdDelete = async (
  packId: string,
  options?: RequestInit,
): Promise<deleteSkillPackApiV1SkillsPacksPackIdDeleteResponse> => {
  return customFetch<deleteSkillPackApiV1SkillsPacksPackIdDeleteResponse>(
    getDeleteSkillPackApiV1SkillsPacksPackIdDeleteUrl(packId),
    {
      ...options,
      method: "DELETE",
    },
  );
};

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

    return deleteSkillPackApiV1SkillsPacksPackIdDelete(packId, requestOptions);
  };

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

export type DeleteSkillPackApiV1SkillsPacksPackIdDeleteMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof deleteSkillPackApiV1SkillsPacksPackIdDelete>>
  >;

export type DeleteSkillPackApiV1SkillsPacksPackIdDeleteMutationError =
  HTTPValidationError;

/**
 * @summary Delete Skill Pack
 */
export const useDeleteSkillPackApiV1SkillsPacksPackIdDelete = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof deleteSkillPackApiV1SkillsPacksPackIdDelete>>,
      TError,
      { packId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof deleteSkillPackApiV1SkillsPacksPackIdDelete>>,
  TError,
  { packId: string },
  TContext
> => {
  return useMutation(
    getDeleteSkillPackApiV1SkillsPacksPackIdDeleteMutationOptions(options),
    queryClient,
  );
};
/**
 * Clone a pack repository and upsert discovered skills from `skills/**\/SKILL.md`.
 * @summary Sync Skill Pack
 */
export type syncSkillPackApiV1SkillsPacksPackIdSyncPostResponse200 = {
  data: SkillPackSyncResponse;
  status: 200;
};

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

export type syncSkillPackApiV1SkillsPacksPackIdSyncPostResponseSuccess =
  syncSkillPackApiV1SkillsPacksPackIdSyncPostResponse200 & {
    headers: Headers;
  };
export type syncSkillPackApiV1SkillsPacksPackIdSyncPostResponseError =
  syncSkillPackApiV1SkillsPacksPackIdSyncPostResponse422 & {
    headers: Headers;
  };

export type syncSkillPackApiV1SkillsPacksPackIdSyncPostResponse =
  | syncSkillPackApiV1SkillsPacksPackIdSyncPostResponseSuccess
  | syncSkillPackApiV1SkillsPacksPackIdSyncPostResponseError;

export const getSyncSkillPackApiV1SkillsPacksPackIdSyncPostUrl = (
  packId: string,
) => {
  return `/api/v1/skills/packs/${packId}/sync`;
};

export const syncSkillPackApiV1SkillsPacksPackIdSyncPost = async (
  packId: string,
  options?: RequestInit,
): Promise<syncSkillPackApiV1SkillsPacksPackIdSyncPostResponse> => {
  return customFetch<syncSkillPackApiV1SkillsPacksPackIdSyncPostResponse>(
    getSyncSkillPackApiV1SkillsPacksPackIdSyncPostUrl(packId),
    {
      ...options,
      method: "POST",
    },
  );
};

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

    return syncSkillPackApiV1SkillsPacksPackIdSyncPost(packId, requestOptions);
  };

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

export type SyncSkillPackApiV1SkillsPacksPackIdSyncPostMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof syncSkillPackApiV1SkillsPacksPackIdSyncPost>>
  >;

export type SyncSkillPackApiV1SkillsPacksPackIdSyncPostMutationError =
  HTTPValidationError;

/**
 * @summary Sync Skill Pack
 */
export const useSyncSkillPackApiV1SkillsPacksPackIdSyncPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof syncSkillPackApiV1SkillsPacksPackIdSyncPost>>,
      TError,
      { packId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof syncSkillPackApiV1SkillsPacksPackIdSyncPost>>,
  TError,
  { packId: string },
  TContext
> => {
  return useMutation(
    getSyncSkillPackApiV1SkillsPacksPackIdSyncPostMutationOptions(options),
    queryClient,
  );
};
