Feat v0.3.7 package audit (#20)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m36s
CI/CD / test-sqlite (push) Successful in 2m41s
CI/CD / build-and-deploy (push) Successful in 1m13s

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #20.
This commit is contained in:
2026-03-28 21:22:39 +00:00
committed by xcaliber
parent d68451fe8e
commit d91ec02dd7
47 changed files with 2067 additions and 53 deletions

View File

@@ -37,6 +37,53 @@ func (h *WorkflowHandler) requireTeamWorkflow(c *gin.Context) bool {
return true
}
// ── Adopt Global Workflow ────────────────────
// AdoptTeamWorkflow claims a global (team_id=NULL) workflow for this team.
// POST /api/v1/teams/:teamId/workflows/:id/adopt
func (h *WorkflowHandler) AdoptTeamWorkflow(c *gin.Context) {
teamID := c.Param("teamId")
wfID := c.Param("id")
w, err := h.stores.Workflows.GetByID(c.Request.Context(), wfID)
if err != nil {
if err == sql.ErrNoRows {
c.JSON(http.StatusNotFound, gin.H{"error": "workflow not found"})
} else {
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to load workflow"})
}
return
}
if w.TeamID != nil {
c.JSON(http.StatusConflict, gin.H{"error": "workflow already belongs to a team"})
return
}
patch := models.WorkflowPatch{TeamID: &teamID}
if err := h.stores.Workflows.Update(c.Request.Context(), wfID, patch); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to adopt workflow"})
return
}
// Return the updated workflow
c.Set("id", wfID)
h.Get(c)
}
// ListGlobalWorkflows returns unowned workflows available for adoption.
// GET /api/v1/teams/:teamId/workflows/available
func (h *WorkflowHandler) ListGlobalWorkflows(c *gin.Context) {
result, err := h.stores.Workflows.ListGlobal(c.Request.Context())
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to list workflows"})
return
}
if result == nil {
result = []models.Workflow{}
}
c.JSON(http.StatusOK, gin.H{"data": result})
}
// ── Workflow CRUD ───────────────────────────
// ListTeamWorkflows returns workflows owned by the team.