/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 06546c5b91aa */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GleanCore } from "../core.js"; import { indexingDocumentsBulkIndex } from "../funcs/indexingDocumentsBulkIndex.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 { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import { unwrapAsync } from "../types/fp.js"; import { useGleanContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type IndexingDocumentsBulkIndexMutationVariables = { request: components.BulkIndexDocumentsRequest; options?: RequestOptions; }; export type IndexingDocumentsBulkIndexMutationData = void; export type IndexingDocumentsBulkIndexMutationError = | GleanBaseError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Bulk index documents * * @remarks * Replaces the documents in a datasource using paginated batch API calls. Please refer to the [bulk indexing](https://developers.glean.com/indexing/documents/bulk-upload-model) documentation for an explanation of how to use bulk endpoints. */ export function useIndexingDocumentsBulkIndexMutation( options?: MutationHookOptions< IndexingDocumentsBulkIndexMutationData, IndexingDocumentsBulkIndexMutationError, IndexingDocumentsBulkIndexMutationVariables >, ): UseMutationResult< IndexingDocumentsBulkIndexMutationData, IndexingDocumentsBulkIndexMutationError, IndexingDocumentsBulkIndexMutationVariables > { const client = useGleanContext(); return useMutation({ ...buildIndexingDocumentsBulkIndexMutation(client, options), ...options, }); } export function mutationKeyIndexingDocumentsBulkIndex(): MutationKey { return ["@gleanwork/api-client", "documents", "bulkIndex"]; } export function buildIndexingDocumentsBulkIndexMutation( client$: GleanCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: IndexingDocumentsBulkIndexMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyIndexingDocumentsBulkIndex(), mutationFn: function indexingDocumentsBulkIndexMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(indexingDocumentsBulkIndex( client$, request, mergedOptions, )); }, }; }