(res: http.ServerResponse, urlPath: string)
| 1378 | } |
| 1379 | |
| 1380 | private async handleSkillDelete(res: http.ServerResponse, urlPath: string): Promise<void> { |
| 1381 | const skillId = urlPath.replace("/api/skill/", ""); |
| 1382 | const skill = this.store.getSkill(skillId); |
| 1383 | if (!skill) { res.writeHead(404, { "Content-Type": "application/json" }); res.end(JSON.stringify({ error: "Skill not found" })); return; } |
| 1384 | try { |
| 1385 | const hub = this.resolveHubConnection(); |
| 1386 | if (hub) { |
| 1387 | await hubRequestJson(hub.hubUrl, hub.userToken, "/api/v1/hub/skills/unpublish", { |
| 1388 | method: "POST", |
| 1389 | body: JSON.stringify({ sourceSkillId: skillId }), |
| 1390 | }).catch(() => {}); |
| 1391 | } |
| 1392 | const db = (this.store as any).db; |
| 1393 | db.prepare("DELETE FROM hub_skills WHERE source_skill_id = ?").run(skillId); |
| 1394 | } catch (_) {} |
| 1395 | try { |
| 1396 | if (skill.dirPath && fs.existsSync(skill.dirPath)) { |
| 1397 | fs.rmSync(skill.dirPath, { recursive: true, force: true }); |
| 1398 | } |
| 1399 | } catch (err) { |
| 1400 | this.log.warn(`Failed to remove skill directory ${skill.dirPath}: ${err}`); |
| 1401 | } |
| 1402 | this.store.deleteSkill(skillId); |
| 1403 | this.jsonResponse(res, { ok: true, skillId }); |
| 1404 | } |
| 1405 | |
| 1406 | private handleSkillUpdate(req: http.IncomingMessage, res: http.ServerResponse, urlPath: string): void { |
| 1407 | const skillId = urlPath.replace("/api/skill/", ""); |
no test coverage detected