/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { SDKCore } from "../core.js"; import { agentVersionsRollbackAgentVersion } from "../funcs/agentVersionsRollbackAgentVersion.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.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 { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { unwrapAsync } from "../types/fp.js"; import { useSDKContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type AgentVersionsRollbackAgentVersionMutationVariables = { request: operations.RollbackAgentVersionRequest; options?: RequestOptions; }; export type AgentVersionsRollbackAgentVersionMutationData = components.Agent; export type AgentVersionsRollbackAgentVersionMutationError = | errors.ErrorEnvelope | SDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Roll back an agent to a version * * @remarks * Restores the target version's configuration as a new current version. History is preserved: the restore is appended as a new version rather than deleting later ones. */ export function useAgentVersionsRollbackAgentVersionMutation( options?: MutationHookOptions< AgentVersionsRollbackAgentVersionMutationData, AgentVersionsRollbackAgentVersionMutationError, AgentVersionsRollbackAgentVersionMutationVariables >, ): UseMutationResult< AgentVersionsRollbackAgentVersionMutationData, AgentVersionsRollbackAgentVersionMutationError, AgentVersionsRollbackAgentVersionMutationVariables > { const client = useSDKContext(); return useMutation({ ...buildAgentVersionsRollbackAgentVersionMutation(client, options), ...options, }); } export function mutationKeyAgentVersionsRollbackAgentVersion(): MutationKey { return ["@meetkai/mka1", "Agent Versions", "rollbackAgentVersion"]; } export function buildAgentVersionsRollbackAgentVersionMutation( client$: SDKCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: AgentVersionsRollbackAgentVersionMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyAgentVersionsRollbackAgentVersion(), mutationFn: function agentVersionsRollbackAgentVersionMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(agentVersionsRollbackAgentVersion( client$, request, mergedOptions, )); }, }; }