mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 02:19:28 +00:00
feat(operations): add create_project operation across agent, mcp, and cli (#529)
* feat(operations): add create_project operation across agent, mcp, and cli * fix(api): remove legacy team creation endpoint * fix(api): preserve ProjectInfo response on POST /teams/:teamId/projects
This commit is contained in:
+12
-21
@@ -18,7 +18,12 @@ import {
|
||||
import { listMembersQuerySchema, AuditAction } from '@shumai/dtos'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import { copyAssetsOp, moveAssetsOp, runOperation } from '@shumai/core/src/operations'
|
||||
import {
|
||||
copyAssetsOp,
|
||||
createProjectOp,
|
||||
moveAssetsOp,
|
||||
runOperation,
|
||||
} from '@shumai/core/src/operations'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -50,27 +55,13 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
const user = c.get('user')
|
||||
const req = c.req.valid('json')
|
||||
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
const newProject = await runOperation(
|
||||
createProjectOp,
|
||||
{ userId: user.id, via: 'api' },
|
||||
{ teamId, ...req },
|
||||
)
|
||||
|
||||
const newProject = await projectService.createProject(user, {
|
||||
teamId,
|
||||
...req,
|
||||
})
|
||||
|
||||
await auditLogService.logAction({
|
||||
action: AuditAction.project_create,
|
||||
teamId,
|
||||
userId: user.id,
|
||||
projectId: newProject.id,
|
||||
itemId: newProject.id,
|
||||
})
|
||||
|
||||
return c.json(newProject)
|
||||
return c.json(await projectService.getProject(newProject.id))
|
||||
})
|
||||
.put('/projects/:projectId', zValidator('json', updateProjectRequestSchema), async (c) => {
|
||||
const projectId = c.req.param('projectId')
|
||||
|
||||
Reference in New Issue
Block a user