/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 9d2afe19e896 */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GleanCore } from "../core.js"; import { clientCollectionsCreate } from "../funcs/clientCollectionsCreate.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; import { GleanBaseError } from "../models/errors/gleanbaseerror.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; import * as errors from "../models/errors/index.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { unwrapAsync } from "../types/fp.js"; import { useGleanContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type ClientCollectionsCreateMutationVariables = { createCollectionRequest: components.CreateCollectionRequest; locale?: string | undefined; options?: RequestOptions; }; export type ClientCollectionsCreateMutationData = operations.CreatecollectionResponse; export type ClientCollectionsCreateMutationError = | errors.CollectionError | GleanBaseError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create Collection * * @remarks * Create a publicly visible (empty) Collection of documents. */ export function useClientCollectionsCreateMutation( options?: MutationHookOptions< ClientCollectionsCreateMutationData, ClientCollectionsCreateMutationError, ClientCollectionsCreateMutationVariables >, ): UseMutationResult< ClientCollectionsCreateMutationData, ClientCollectionsCreateMutationError, ClientCollectionsCreateMutationVariables > { const client = useGleanContext(); return useMutation({ ...buildClientCollectionsCreateMutation(client, options), ...options, }); } export function mutationKeyClientCollectionsCreate(): MutationKey { return ["@gleanwork/api-client", "collections", "create"]; } export function buildClientCollectionsCreateMutation( client$: GleanCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: ClientCollectionsCreateMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyClientCollectionsCreate(), mutationFn: function clientCollectionsCreateMutationFn({ createCollectionRequest, locale, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(clientCollectionsCreate( client$, createCollectionRequest, locale, mergedOptions, )); }, }; }