2026-02-21 02:48:20 +08:00
|
|
|
import {
|
|
|
|
|
apiAdminGet,
|
|
|
|
|
apiSuperAdminDelete,
|
|
|
|
|
apiSuperAdminGet,
|
|
|
|
|
apiSuperAdminPost,
|
|
|
|
|
apiSuperAdminPut
|
|
|
|
|
} from './base'
|
|
|
|
|
|
|
|
|
|
const BASE_URL = '/api/system/skills'
|
|
|
|
|
|
|
|
|
|
export const listSkills = async () => {
|
|
|
|
|
return apiAdminGet(BASE_URL)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const importSkillZip = async (file) => {
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append('file', file)
|
|
|
|
|
return apiSuperAdminPost(`${BASE_URL}/import`, formData)
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 14:44:33 +08:00
|
|
|
export const listRemoteSkills = async (source) => {
|
|
|
|
|
return apiSuperAdminPost(`${BASE_URL}/remote/list`, { source })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const installRemoteSkill = async (payload) => {
|
|
|
|
|
return apiSuperAdminPost(`${BASE_URL}/remote/install`, payload)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-22 17:42:37 +08:00
|
|
|
export const getSkillDependencyOptions = async () => {
|
|
|
|
|
return apiSuperAdminGet(`${BASE_URL}/dependency-options`)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-28 17:53:53 +08:00
|
|
|
export const listBuiltinSkills = async () => {
|
|
|
|
|
return apiSuperAdminGet(`${BASE_URL}/builtin`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const installBuiltinSkill = async (slug) => {
|
|
|
|
|
return apiSuperAdminPost(`${BASE_URL}/builtin/${encodeURIComponent(slug)}/install`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const updateBuiltinSkill = async (slug, force = false) => {
|
|
|
|
|
return apiSuperAdminPost(`${BASE_URL}/builtin/${encodeURIComponent(slug)}/update`, { force })
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-21 02:48:20 +08:00
|
|
|
export const getSkillTree = async (slug) => {
|
|
|
|
|
return apiSuperAdminGet(`${BASE_URL}/${encodeURIComponent(slug)}/tree`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getSkillFile = async (slug, path) => {
|
2026-03-04 04:13:05 +08:00
|
|
|
return apiSuperAdminGet(
|
|
|
|
|
`${BASE_URL}/${encodeURIComponent(slug)}/file?path=${encodeURIComponent(path)}`
|
|
|
|
|
)
|
2026-02-21 02:48:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const createSkillFile = async (slug, payload) => {
|
|
|
|
|
return apiSuperAdminPost(`${BASE_URL}/${encodeURIComponent(slug)}/file`, payload)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const updateSkillFile = async (slug, payload) => {
|
|
|
|
|
return apiSuperAdminPut(`${BASE_URL}/${encodeURIComponent(slug)}/file`, payload)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-22 17:42:37 +08:00
|
|
|
export const updateSkillDependencies = async (slug, payload) => {
|
|
|
|
|
return apiSuperAdminPut(`${BASE_URL}/${encodeURIComponent(slug)}/dependencies`, payload)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-21 02:48:20 +08:00
|
|
|
export const deleteSkillFile = async (slug, path) => {
|
2026-03-04 04:13:05 +08:00
|
|
|
return apiSuperAdminDelete(
|
|
|
|
|
`${BASE_URL}/${encodeURIComponent(slug)}/file?path=${encodeURIComponent(path)}`
|
|
|
|
|
)
|
2026-02-21 02:48:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const exportSkill = async (slug) => {
|
|
|
|
|
return apiSuperAdminGet(`${BASE_URL}/${encodeURIComponent(slug)}/export`, {}, 'blob')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const deleteSkill = async (slug) => {
|
|
|
|
|
return apiSuperAdminDelete(`${BASE_URL}/${encodeURIComponent(slug)}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const skillApi = {
|
|
|
|
|
listSkills,
|
|
|
|
|
importSkillZip,
|
2026-04-01 14:44:33 +08:00
|
|
|
listRemoteSkills,
|
|
|
|
|
installRemoteSkill,
|
2026-02-22 17:42:37 +08:00
|
|
|
getSkillDependencyOptions,
|
2026-03-28 17:53:53 +08:00
|
|
|
listBuiltinSkills,
|
|
|
|
|
installBuiltinSkill,
|
|
|
|
|
updateBuiltinSkill,
|
2026-02-21 02:48:20 +08:00
|
|
|
getSkillTree,
|
|
|
|
|
getSkillFile,
|
|
|
|
|
createSkillFile,
|
|
|
|
|
updateSkillFile,
|
2026-02-22 17:42:37 +08:00
|
|
|
updateSkillDependencies,
|
2026-02-21 02:48:20 +08:00
|
|
|
deleteSkillFile,
|
|
|
|
|
exportSkill,
|
|
|
|
|
deleteSkill
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default skillApi
|