(params: {
skillId: string
workspaceId: string
})
| 79 | * Returns true if the skill was found and deleted, false otherwise. |
| 80 | */ |
| 81 | export async function deleteSkill(params: { |
| 82 | skillId: string |
| 83 | workspaceId: string |
| 84 | }): Promise<boolean> { |
| 85 | // Built-in template skills have no DB row and cannot be deleted. |
| 86 | if (isBuiltinSkillId(params.skillId)) return false |
| 87 | |
| 88 | const existing = await db |
| 89 | .select({ id: skill.id }) |
| 90 | .from(skill) |
| 91 | .where(and(eq(skill.id, params.skillId), eq(skill.workspaceId, params.workspaceId))) |
| 92 | .limit(1) |
| 93 | |
| 94 | if (existing.length === 0) return false |
| 95 | |
| 96 | await db |
| 97 | .delete(skill) |
| 98 | .where(and(eq(skill.id, params.skillId), eq(skill.workspaceId, params.workspaceId))) |
| 99 | |
| 100 | logger.info(`Deleted skill ${params.skillId}`) |
| 101 | return true |
| 102 | } |
| 103 | |
| 104 | /** Whether a given skill in an upsert was newly inserted or an existing row updated. */ |
| 105 | export type SkillUpsertOperation = 'created' | 'updated' |
no test coverage detected