Skip to content

Commit c6ac0b4

Browse files
committed
Agent subdir
1 parent b07925f commit c6ac0b4

File tree

10 files changed

+689
-40
lines changed

10 files changed

+689
-40
lines changed

apps/sim/app/api/skills/route.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { db } from '@sim/db'
2-
import { skill } from '@sim/db/schema'
31
import { createLogger } from '@sim/logger'
4-
import { and, desc, eq } from 'drizzle-orm'
52
import { type NextRequest, NextResponse } from 'next/server'
63
import { z } from 'zod'
74
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
85
import { generateRequestId } from '@/lib/core/utils/request'
9-
import { upsertSkills } from '@/lib/workflows/skills/operations'
6+
import { deleteSkill, listSkills, upsertSkills } from '@/lib/workflows/skills/operations'
107
import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils'
118

129
const logger = createLogger('SkillsAPI')
@@ -53,11 +50,7 @@ export async function GET(request: NextRequest) {
5350
return NextResponse.json({ error: 'Access denied' }, { status: 403 })
5451
}
5552

56-
const result = await db
57-
.select()
58-
.from(skill)
59-
.where(eq(skill.workspaceId, workspaceId))
60-
.orderBy(desc(skill.createdAt))
53+
const result = await listSkills({ workspaceId })
6154

6255
return NextResponse.json({ data: result }, { status: 200 })
6356
} catch (error) {
@@ -159,20 +152,12 @@ export async function DELETE(request: NextRequest) {
159152
return NextResponse.json({ error: 'Write permission required' }, { status: 403 })
160153
}
161154

162-
const existingSkill = await db.select().from(skill).where(eq(skill.id, skillId)).limit(1)
163-
164-
if (existingSkill.length === 0) {
155+
const deleted = await deleteSkill({ skillId, workspaceId })
156+
if (!deleted) {
165157
logger.warn(`[${requestId}] Skill not found: ${skillId}`)
166158
return NextResponse.json({ error: 'Skill not found' }, { status: 404 })
167159
}
168160

169-
if (existingSkill[0].workspaceId !== workspaceId) {
170-
logger.warn(`[${requestId}] Skill ${skillId} does not belong to workspace ${workspaceId}`)
171-
return NextResponse.json({ error: 'Skill not found' }, { status: 404 })
172-
}
173-
174-
await db.delete(skill).where(and(eq(skill.id, skillId), eq(skill.workspaceId, workspaceId)))
175-
176161
logger.info(`[${requestId}] Deleted skill: ${skillId}`)
177162
return NextResponse.json({ success: true })
178163
} catch (error) {

0 commit comments

Comments
 (0)