feat(agent): return updated agent data from updateAgent method

Add response parsing and return type to updateAgent to provide updated agent data to callers
This commit is contained in:
icarus 2025-09-18 14:35:57 +08:00
parent 524098d6d3
commit 8d92b515ab

View File

@ -9,7 +9,9 @@ import {
GetAgentResponseSchema, GetAgentResponseSchema,
type ListAgentsResponse, type ListAgentsResponse,
ListAgentsResponseSchema, ListAgentsResponseSchema,
UpdateAgentRequest UpdateAgentRequest,
UpdateAgentResponse,
UpdateAgentResponseSchema
} from '@types' } from '@types'
import { Axios, AxiosRequestConfig, isAxiosError } from 'axios' import { Axios, AxiosRequestConfig, isAxiosError } from 'axios'
@ -87,13 +89,15 @@ export class AgentApiClient {
} }
} }
public async updateAgent(id: string, agent: Partial<AgentForm>): Promise<void> { public async updateAgent(id: string, agent: Partial<AgentForm>): Promise<UpdateAgentResponse> {
const url = `/${this.apiVersion}/agents/${id}` const url = `/${this.apiVersion}/agents/${id}`
try { try {
const payload = { const payload = {
...agent ...agent
} satisfies UpdateAgentRequest } satisfies UpdateAgentRequest
await this.axios.patch(url, payload) const response = await this.axios.patch(url, payload)
const data = UpdateAgentResponseSchema.parse(response.data)
return data
} catch (error) { } catch (error) {
throw processError(error, 'Failed to updateAgent.') throw processError(error, 'Failed to updateAgent.')
} }