feat: 增强 agent_assets 功能,支持更多资产操作
This commit is contained in:
@@ -60,6 +60,10 @@ function buildQuery(params = {}) {
|
||||
search.set('limit', String(params.limit))
|
||||
}
|
||||
|
||||
if (params.version) {
|
||||
search.set('version', String(params.version))
|
||||
}
|
||||
|
||||
if (params.agent) {
|
||||
search.set('agent', params.agent)
|
||||
}
|
||||
@@ -80,10 +84,66 @@ export function fetchAgentAssetDetail(assetId) {
|
||||
return apiRequest(`/agent-assets/${assetId}`)
|
||||
}
|
||||
|
||||
export function fetchAgentAssetSpreadsheetOnlyOfficeConfig(assetId, version = '') {
|
||||
const query = buildQuery({ version })
|
||||
return apiRequest(`/agent-assets/${assetId}/spreadsheet/onlyoffice-config${query}`)
|
||||
}
|
||||
|
||||
export function fetchAgentAssetSpreadsheetBlob(assetId, version = '', disposition = 'inline') {
|
||||
const search = new URLSearchParams()
|
||||
if (version) {
|
||||
search.set('version', String(version).trim())
|
||||
}
|
||||
if (disposition) {
|
||||
search.set('disposition', String(disposition).trim())
|
||||
}
|
||||
const query = search.toString()
|
||||
return apiRequest(`/agent-assets/${assetId}/spreadsheet/content${query ? `?${query}` : ''}`, {
|
||||
responseType: 'blob',
|
||||
contentType: null
|
||||
})
|
||||
}
|
||||
|
||||
export function uploadAgentAssetSpreadsheet(assetId, file, options = {}) {
|
||||
return apiRequest(
|
||||
`/agent-assets/${assetId}/spreadsheet/upload?filename=${encodeURIComponent(file.name)}`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: file,
|
||||
contentType: file.type || 'application/octet-stream',
|
||||
headers: buildWriteHeaders(options)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function importAgentAssetSpreadsheetContent(assetId, file, options = {}) {
|
||||
return apiRequest(
|
||||
`/agent-assets/${assetId}/spreadsheet/import-content?filename=${encodeURIComponent(file.name)}`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: file,
|
||||
contentType: file.type || 'application/octet-stream',
|
||||
headers: buildWriteHeaders(options)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchAgentAssetVersions(assetId, limit = 5) {
|
||||
return apiRequest(`/agent-assets/${assetId}/versions${buildQuery({ limit })}`)
|
||||
}
|
||||
|
||||
export function fetchAgentAssetVersionTimeline(assetId) {
|
||||
return apiRequest(`/agent-assets/${assetId}/version-timeline`)
|
||||
}
|
||||
|
||||
export function compareAgentAssetSpreadsheetVersions(assetId, baseVersion, targetVersion) {
|
||||
const query = new URLSearchParams({
|
||||
base_version: String(baseVersion || '').trim(),
|
||||
target_version: String(targetVersion || '').trim()
|
||||
})
|
||||
return apiRequest(`/agent-assets/${assetId}/versions/compare?${query.toString()}`)
|
||||
}
|
||||
|
||||
export function updateAgentAsset(assetId, payload, options = {}) {
|
||||
return apiRequest(`/agent-assets/${assetId}`, {
|
||||
method: 'PATCH',
|
||||
@@ -115,6 +175,13 @@ export function activateAgentAsset(assetId, options = {}) {
|
||||
})
|
||||
}
|
||||
|
||||
export function restoreAgentAssetVersion(assetId, version, options = {}) {
|
||||
return apiRequest(`/agent-assets/${assetId}/versions/${encodeURIComponent(version)}/restore`, {
|
||||
method: 'POST',
|
||||
headers: buildWriteHeaders(options)
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchAgentRuns(params = {}) {
|
||||
return apiRequest(`/agent-runs${buildQuery(params)}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user