Fix BASE_URL config loading, add tasks/projects; robust .env path resolution

- Config: try ENV_FILE, .env, ../.env for loading; trim trailing slash from BaseURL
- Log BASE_URL at server startup for verification
- .env.example: document BASE_URL
- Tasks, projects, tags, migrations and related API/handlers

Made-with: Cursor
This commit is contained in:
Michilis
2026-03-09 18:57:51 +00:00
parent 75105b8b46
commit bd24545b7b
61 changed files with 6595 additions and 90 deletions

View File

@@ -0,0 +1,185 @@
package handlers
import (
"net/http"
"github.com/calendarapi/internal/middleware"
"github.com/calendarapi/internal/models"
"github.com/calendarapi/internal/service"
"github.com/calendarapi/internal/utils"
"github.com/go-chi/chi/v5"
)
type ProjectHandler struct {
projectSvc *service.ProjectService
}
func NewProjectHandler(projectSvc *service.ProjectService) *ProjectHandler {
return &ProjectHandler{projectSvc: projectSvc}
}
func (h *ProjectHandler) List(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
projects, err := h.projectSvc.List(r.Context(), userID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteList(w, projects, models.PageInfo{Limit: len(projects)})
}
func (h *ProjectHandler) Create(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
var req struct {
Name string `json:"name"`
Color *string `json:"color"`
IsShared *bool `json:"is_shared"`
Deadline *string `json:"deadline"`
SortOrder *int `json:"sort_order"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
createReq := service.CreateProjectRequest{
Name: req.Name,
Color: req.Color,
IsShared: req.IsShared,
SortOrder: req.SortOrder,
}
if req.Deadline != nil {
if t, err := utils.ParseTime(*req.Deadline); err == nil {
createReq.Deadline = &t
}
}
project, err := h.projectSvc.Create(r.Context(), userID, createReq)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"project": project})
}
func (h *ProjectHandler) Get(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
projectID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
project, err := h.projectSvc.Get(r.Context(), userID, projectID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"project": project})
}
func (h *ProjectHandler) Update(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
projectID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
var req struct {
Name *string `json:"name"`
Color *string `json:"color"`
IsShared *bool `json:"is_shared"`
Deadline *string `json:"deadline"`
SortOrder *int `json:"sort_order"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
updateReq := service.UpdateProjectRequest{
Name: req.Name,
Color: req.Color,
IsShared: req.IsShared,
SortOrder: req.SortOrder,
}
if req.Deadline != nil {
if t, err := utils.ParseTime(*req.Deadline); err == nil {
updateReq.Deadline = &t
}
}
project, err := h.projectSvc.Update(r.Context(), userID, projectID, updateReq)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"project": project})
}
func (h *ProjectHandler) Delete(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
projectID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
if err := h.projectSvc.Delete(r.Context(), userID, projectID); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}
func (h *ProjectHandler) Share(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
projectID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
var req struct {
Target struct {
Email string `json:"email"`
} `json:"target"`
Role string `json:"role"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
if err := h.projectSvc.Share(r.Context(), userID, projectID, req.Target.Email, req.Role); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}
func (h *ProjectHandler) ListMembers(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
projectID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
members, err := h.projectSvc.ListMembers(r.Context(), userID, projectID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"members": members})
}

View File

@@ -0,0 +1,159 @@
package handlers
import (
"net/http"
"github.com/calendarapi/internal/middleware"
"github.com/calendarapi/internal/models"
"github.com/calendarapi/internal/service"
"github.com/calendarapi/internal/utils"
"github.com/go-chi/chi/v5"
)
type TagHandler struct {
tagSvc *service.TagService
}
func NewTagHandler(tagSvc *service.TagService) *TagHandler {
return &TagHandler{tagSvc: tagSvc}
}
func (h *TagHandler) List(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
tags, err := h.tagSvc.List(r.Context(), userID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteList(w, tags, models.PageInfo{Limit: len(tags)})
}
func (h *TagHandler) Create(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
var req struct {
Name string `json:"name"`
Color *string `json:"color"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
tag, err := h.tagSvc.Create(r.Context(), userID, service.CreateTagRequest{
Name: req.Name,
Color: req.Color,
})
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"tag": tag})
}
func (h *TagHandler) Get(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
tagID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
tag, err := h.tagSvc.Get(r.Context(), userID, tagID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"tag": tag})
}
func (h *TagHandler) Update(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
tagID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
var req struct {
Name *string `json:"name"`
Color *string `json:"color"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
tag, err := h.tagSvc.Update(r.Context(), userID, tagID, service.UpdateTagRequest{
Name: req.Name,
Color: req.Color,
})
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"tag": tag})
}
func (h *TagHandler) Delete(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
tagID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
if err := h.tagSvc.Delete(r.Context(), userID, tagID); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}
func (h *TagHandler) AttachToTask(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
tagID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
taskID, err := utils.ValidateUUID(chi.URLParam(r, "taskId"))
if err != nil {
utils.WriteError(w, err)
return
}
if err := h.tagSvc.AttachToTask(r.Context(), userID, tagID, taskID); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}
func (h *TagHandler) DetachFromTask(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
tagID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
taskID, err := utils.ValidateUUID(chi.URLParam(r, "taskId"))
if err != nil {
utils.WriteError(w, err)
return
}
if err := h.tagSvc.DetachFromTask(r.Context(), userID, tagID, taskID); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}

View File

@@ -0,0 +1,263 @@
package handlers
import (
"net/http"
"strconv"
"github.com/calendarapi/internal/middleware"
"github.com/calendarapi/internal/models"
"github.com/calendarapi/internal/service"
"github.com/calendarapi/internal/utils"
"github.com/go-chi/chi/v5"
)
type TaskHandler struct {
taskSvc *service.TaskService
}
func NewTaskHandler(taskSvc *service.TaskService) *TaskHandler {
return &TaskHandler{taskSvc: taskSvc}
}
func (h *TaskHandler) List(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
q := r.URL.Query()
params := service.ListTasksParams{
Limit: 50,
}
if s := q.Get("status"); s != "" {
params.Status = &s
}
if p := q.Get("priority"); p != "" {
params.Priority = &p
}
if pid := q.Get("project_id"); pid != "" {
if id, err := utils.ValidateUUID(pid); err == nil {
params.ProjectID = &id
}
}
if df := q.Get("due_from"); df != "" {
if t, err := utils.ParseTime(df); err == nil {
params.DueFrom = &t
}
}
if dt := q.Get("due_to"); dt != "" {
if t, err := utils.ParseTime(dt); err == nil {
params.DueTo = &t
}
}
if l := q.Get("limit"); l != "" {
if v, err := strconv.Atoi(l); err == nil {
params.Limit = v
}
}
params.Cursor = q.Get("cursor")
tasks, cursor, err := h.taskSvc.List(r.Context(), userID, params)
if err != nil {
utils.WriteError(w, err)
return
}
limit := int(utils.ClampLimit(params.Limit))
page := models.PageInfo{Limit: limit}
if cursor != nil {
page.NextCursor = cursor
}
utils.WriteList(w, tasks, page)
}
func (h *TaskHandler) Create(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
var req struct {
Title string `json:"title"`
Description *string `json:"description"`
Status *string `json:"status"`
Priority *string `json:"priority"`
DueDate *string `json:"due_date"`
ProjectID *string `json:"project_id"`
ParentID *string `json:"parent_id"`
SortOrder *int `json:"sort_order"`
RecurrenceRule *string `json:"recurrence_rule"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
createReq := service.CreateTaskRequest{
Title: req.Title,
Description: req.Description,
Status: req.Status,
Priority: req.Priority,
SortOrder: req.SortOrder,
RecurrenceRule: req.RecurrenceRule,
}
if req.DueDate != nil {
if t, err := utils.ParseTime(*req.DueDate); err == nil {
createReq.DueDate = &t
}
}
if req.ProjectID != nil {
if id, err := utils.ValidateUUID(*req.ProjectID); err == nil {
createReq.ProjectID = &id
}
}
if req.ParentID != nil {
if id, err := utils.ValidateUUID(*req.ParentID); err == nil {
createReq.ParentID = &id
}
}
task, err := h.taskSvc.Create(r.Context(), userID, createReq)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"task": task})
}
func (h *TaskHandler) Get(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
task, err := h.taskSvc.Get(r.Context(), userID, taskID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"task": task})
}
func (h *TaskHandler) Update(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
var req struct {
Title *string `json:"title"`
Description *string `json:"description"`
Status *string `json:"status"`
Priority *string `json:"priority"`
DueDate *string `json:"due_date"`
ProjectID *string `json:"project_id"`
SortOrder *int `json:"sort_order"`
RecurrenceRule *string `json:"recurrence_rule"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
updateReq := service.UpdateTaskRequest{
Title: req.Title,
Description: req.Description,
Status: req.Status,
Priority: req.Priority,
SortOrder: req.SortOrder,
RecurrenceRule: req.RecurrenceRule,
}
if req.DueDate != nil {
if t, err := utils.ParseTime(*req.DueDate); err == nil {
updateReq.DueDate = &t
}
}
if req.ProjectID != nil {
if id, err := utils.ValidateUUID(*req.ProjectID); err == nil {
updateReq.ProjectID = &id
}
}
task, err := h.taskSvc.Update(r.Context(), userID, taskID, updateReq)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"task": task})
}
func (h *TaskHandler) Delete(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
permanent := r.URL.Query().Get("permanent") == "true"
if err := h.taskSvc.Delete(r.Context(), userID, taskID, permanent); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}
func (h *TaskHandler) MarkComplete(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
task, err := h.taskSvc.MarkComplete(r.Context(), userID, taskID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"task": task})
}
func (h *TaskHandler) MarkUncomplete(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
var req struct {
Status *string `json:"status"`
}
_ = utils.DecodeJSON(r, &req)
task, err := h.taskSvc.MarkUncomplete(r.Context(), userID, taskID, req.Status)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"task": task})
}
func (h *TaskHandler) ListSubtasks(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
tasks, err := h.taskSvc.ListSubtasks(r.Context(), userID, taskID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteList(w, tasks, models.PageInfo{Limit: len(tasks)})
}

View File

@@ -0,0 +1,88 @@
package handlers
import (
"net/http"
"github.com/calendarapi/internal/middleware"
"github.com/calendarapi/internal/models"
"github.com/calendarapi/internal/service"
"github.com/calendarapi/internal/utils"
"github.com/go-chi/chi/v5"
)
type TaskDependencyHandler struct {
depSvc *service.TaskDependencyService
}
func NewTaskDependencyHandler(depSvc *service.TaskDependencyService) *TaskDependencyHandler {
return &TaskDependencyHandler{depSvc: depSvc}
}
func (h *TaskDependencyHandler) ListBlockers(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
tasks, err := h.depSvc.ListBlockers(r.Context(), userID, taskID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteList(w, tasks, models.PageInfo{Limit: len(tasks)})
}
func (h *TaskDependencyHandler) Add(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
var req struct {
BlocksTaskID string `json:"blocks_task_id"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
blocksTaskID, err := utils.ValidateUUID(req.BlocksTaskID)
if err != nil {
utils.WriteError(w, err)
return
}
if err := h.depSvc.Add(r.Context(), userID, taskID, blocksTaskID); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}
func (h *TaskDependencyHandler) Remove(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
blocksTaskID, err := utils.ValidateUUID(chi.URLParam(r, "blocksTaskId"))
if err != nil {
utils.WriteError(w, err)
return
}
if err := h.depSvc.Remove(r.Context(), userID, taskID, blocksTaskID); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}

View File

@@ -0,0 +1,94 @@
package handlers
import (
"net/http"
"github.com/calendarapi/internal/middleware"
"github.com/calendarapi/internal/models"
"github.com/calendarapi/internal/service"
"github.com/calendarapi/internal/utils"
"github.com/go-chi/chi/v5"
)
type TaskReminderHandler struct {
reminderSvc *service.TaskReminderService
}
func NewTaskReminderHandler(reminderSvc *service.TaskReminderService) *TaskReminderHandler {
return &TaskReminderHandler{reminderSvc: reminderSvc}
}
func (h *TaskReminderHandler) List(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
reminders, err := h.reminderSvc.List(r.Context(), userID, taskID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteList(w, reminders, models.PageInfo{Limit: len(reminders)})
}
func (h *TaskReminderHandler) Add(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
var req struct {
Type string `json:"type"`
Config map[string]interface{} `json:"config"`
ScheduledAt string `json:"scheduled_at"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
t, err := utils.ParseTime(req.ScheduledAt)
if err != nil {
utils.WriteError(w, models.NewValidationError("invalid scheduled_at"))
return
}
reminder, err := h.reminderSvc.Create(r.Context(), userID, taskID, service.CreateTaskReminderRequest{
Type: req.Type,
Config: req.Config,
ScheduledAt: t,
})
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"reminder": reminder})
}
func (h *TaskReminderHandler) Delete(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
taskID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
reminderID, err := utils.ValidateUUID(chi.URLParam(r, "reminderId"))
if err != nil {
utils.WriteError(w, err)
return
}
if err := h.reminderSvc.Delete(r.Context(), userID, taskID, reminderID); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}

View File

@@ -0,0 +1,73 @@
package handlers
import (
"net/http"
"github.com/calendarapi/internal/middleware"
"github.com/calendarapi/internal/models"
"github.com/calendarapi/internal/service"
"github.com/calendarapi/internal/utils"
"github.com/go-chi/chi/v5"
)
type TaskWebhookHandler struct {
webhookSvc *service.TaskWebhookService
}
func NewTaskWebhookHandler(webhookSvc *service.TaskWebhookService) *TaskWebhookHandler {
return &TaskWebhookHandler{webhookSvc: webhookSvc}
}
func (h *TaskWebhookHandler) List(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
webhooks, err := h.webhookSvc.List(r.Context(), userID)
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteList(w, webhooks, models.PageInfo{Limit: len(webhooks)})
}
func (h *TaskWebhookHandler) Create(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
var req struct {
URL string `json:"url"`
Events []string `json:"events"`
Secret *string `json:"secret"`
}
if err := utils.DecodeJSON(r, &req); err != nil {
utils.WriteError(w, err)
return
}
webhook, err := h.webhookSvc.Create(r.Context(), userID, service.TaskWebhookCreateRequest{
URL: req.URL,
Events: req.Events,
Secret: req.Secret,
})
if err != nil {
utils.WriteError(w, err)
return
}
utils.WriteJSON(w, http.StatusOK, map[string]interface{}{"webhook": webhook})
}
func (h *TaskWebhookHandler) Delete(w http.ResponseWriter, r *http.Request) {
userID, _ := middleware.GetUserID(r.Context())
webhookID, err := utils.ValidateUUID(chi.URLParam(r, "id"))
if err != nil {
utils.WriteError(w, err)
return
}
if err := h.webhookSvc.Delete(r.Context(), userID, webhookID); err != nil {
utils.WriteError(w, err)
return
}
utils.WriteOK(w)
}

View File

@@ -33,7 +33,11 @@
{ "name": "Availability", "description": "Calendar availability queries" },
{ "name": "Booking", "description": "Public booking links and reservations" },
{ "name": "ICS", "description": "ICS calendar import and export" },
{ "name": "Subscriptions", "description": "Calendar subscriptions (external iCal feeds)" }
{ "name": "Subscriptions", "description": "Calendar subscriptions (external iCal feeds)" },
{ "name": "Tasks", "description": "Task and to-do management" },
{ "name": "Projects", "description": "Project/list grouping for tasks" },
{ "name": "Tags", "description": "Tag management for tasks" },
{ "name": "Webhooks", "description": "Task webhook configuration" }
],
"security": [
{ "BearerAuth": [] },

View File

@@ -0,0 +1,229 @@
{
"paths": {
"/projects": {
"get": {
"tags": ["Projects"],
"summary": "List projects",
"description": "Returns the authenticated user's projects (owned and shared). Requires `tasks:read` scope.",
"operationId": "listProjects",
"parameters": [
{ "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 200, "default": 50 } },
{ "name": "cursor", "in": "query", "schema": { "type": "string" }, "description": "Pagination cursor" }
],
"responses": {
"200": {
"description": "List of projects",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["items", "page"],
"properties": {
"items": { "type": "array", "items": { "$ref": "#/components/schemas/Project" } },
"page": { "$ref": "#/components/schemas/PageInfo" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"post": {
"tags": ["Projects"],
"summary": "Create a project",
"description": "Creates a new project for the authenticated user. Requires `tasks:write` scope.",
"operationId": "createProject",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["name"],
"properties": {
"name": { "type": "string", "minLength": 1, "maxLength": 100 },
"color": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$", "example": "#3B82F6" },
"deadline": { "type": "string", "format": "date-time" },
"sort_order": { "type": "integer" }
}
}
}
}
},
"responses": {
"200": {
"description": "Project created",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["project"],
"properties": {
"project": { "$ref": "#/components/schemas/Project" }
}
}
}
}
},
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/projects/{id}": {
"get": {
"tags": ["Projects"],
"summary": "Get a project",
"description": "Returns a single project by ID. User must be owner or member. Requires `tasks:read` scope.",
"operationId": "getProject",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": {
"description": "Project details",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["project"],
"properties": {
"project": { "$ref": "#/components/schemas/Project" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Project not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"put": {
"tags": ["Projects"],
"summary": "Update a project",
"description": "Updates a project. Requires `tasks:write` scope and owner/editor role.",
"operationId": "updateProject",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": { "type": "string", "minLength": 1, "maxLength": 100 },
"color": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" },
"deadline": { "type": "string", "format": "date-time", "nullable": true },
"sort_order": { "type": "integer" }
}
}
}
}
},
"responses": {
"200": {
"description": "Project updated",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["project"],
"properties": {
"project": { "$ref": "#/components/schemas/Project" }
}
}
}
}
},
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Project not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"delete": {
"tags": ["Projects"],
"summary": "Delete a project",
"description": "Deletes a project. Requires `tasks:write` scope and owner role.",
"operationId": "deleteProject",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": { "description": "Project deleted", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Project not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/projects/{id}/share": {
"post": {
"tags": ["Projects"],
"summary": "Share project",
"description": "Shares a project with a user by email. Requires `tasks:write` scope and owner/editor role.",
"operationId": "shareProject",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["email", "role"],
"properties": {
"email": { "type": "string", "format": "email" },
"role": { "type": "string", "enum": ["editor", "viewer"] }
}
}
}
}
},
"responses": {
"200": { "description": "Project shared", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Project not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/projects/{id}/members": {
"get": {
"tags": ["Projects"],
"summary": "List project members",
"description": "Returns members of a project. Requires `tasks:read` scope.",
"operationId": "listProjectMembers",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": {
"description": "List of project members",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["items"],
"properties": {
"items": { "type": "array", "items": { "$ref": "#/components/schemas/ProjectMember" } }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Project not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
}
}
}

View File

@@ -188,6 +188,86 @@
"start": { "type": "string", "format": "date-time" },
"end": { "type": "string", "format": "date-time" }
}
},
"Task": {
"type": "object",
"required": ["id", "title", "status", "priority", "owner_id", "created_at", "updated_at"],
"properties": {
"id": { "type": "string", "format": "uuid" },
"title": { "type": "string", "minLength": 1, "maxLength": 500 },
"description": { "type": "string", "nullable": true, "description": "Markdown supported" },
"status": { "type": "string", "enum": ["todo", "in_progress", "done", "archived"] },
"priority": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
"due_date": { "type": "string", "format": "date-time", "nullable": true },
"completed_at": { "type": "string", "format": "date-time", "nullable": true },
"created_at": { "type": "string", "format": "date-time" },
"updated_at": { "type": "string", "format": "date-time" },
"owner_id": { "type": "string", "format": "uuid" },
"project_id": { "type": "string", "format": "uuid", "nullable": true },
"parent_id": { "type": "string", "format": "uuid", "nullable": true },
"subtasks": { "type": "array", "items": { "$ref": "#/components/schemas/Task" } },
"tags": { "type": "array", "items": { "$ref": "#/components/schemas/Tag" } },
"completion_percentage": { "type": "integer", "nullable": true }
}
},
"Project": {
"type": "object",
"required": ["id", "owner_id", "name", "color", "is_shared", "created_at", "updated_at"],
"properties": {
"id": { "type": "string", "format": "uuid" },
"owner_id": { "type": "string", "format": "uuid" },
"name": { "type": "string", "minLength": 1, "maxLength": 100 },
"color": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$", "example": "#3B82F6" },
"is_shared": { "type": "boolean" },
"deadline": { "type": "string", "format": "date-time", "nullable": true },
"sort_order": { "type": "integer" },
"created_at": { "type": "string", "format": "date-time" },
"updated_at": { "type": "string", "format": "date-time" }
}
},
"Tag": {
"type": "object",
"required": ["id", "owner_id", "name", "color", "created_at"],
"properties": {
"id": { "type": "string", "format": "uuid" },
"owner_id": { "type": "string", "format": "uuid" },
"name": { "type": "string", "minLength": 1, "maxLength": 50 },
"color": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$", "example": "#6B7280" },
"created_at": { "type": "string", "format": "date-time" }
}
},
"ProjectMember": {
"type": "object",
"required": ["user_id", "email", "role"],
"properties": {
"user_id": { "type": "string", "format": "uuid" },
"email": { "type": "string", "format": "email" },
"role": { "type": "string", "enum": ["owner", "editor", "viewer"] }
}
},
"TaskReminder": {
"type": "object",
"required": ["id", "task_id", "type", "scheduled_at", "created_at"],
"properties": {
"id": { "type": "string", "format": "uuid" },
"task_id": { "type": "string", "format": "uuid" },
"type": { "type": "string", "enum": ["push", "email", "webhook", "telegram", "nostr"] },
"config": { "type": "object", "additionalProperties": true },
"scheduled_at": { "type": "string", "format": "date-time" },
"created_at": { "type": "string", "format": "date-time" }
}
},
"TaskWebhook": {
"type": "object",
"required": ["id", "owner_id", "url", "events", "created_at"],
"properties": {
"id": { "type": "string", "format": "uuid" },
"owner_id": { "type": "string", "format": "uuid" },
"url": { "type": "string", "format": "uri" },
"events": { "type": "array", "items": { "type": "string", "enum": ["created", "status_change", "completion"] } },
"secret": { "type": "string", "nullable": true },
"created_at": { "type": "string", "format": "date-time" }
}
}
}
}

View File

@@ -0,0 +1,198 @@
{
"paths": {
"/tags": {
"get": {
"tags": ["Tags"],
"summary": "List tags",
"description": "Returns the authenticated user's tags. Requires `tasks:read` scope.",
"operationId": "listTags",
"parameters": [
{ "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 200, "default": 50 } },
{ "name": "cursor", "in": "query", "schema": { "type": "string" }, "description": "Pagination cursor" }
],
"responses": {
"200": {
"description": "List of tags",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["items", "page"],
"properties": {
"items": { "type": "array", "items": { "$ref": "#/components/schemas/Tag" } },
"page": { "$ref": "#/components/schemas/PageInfo" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"post": {
"tags": ["Tags"],
"summary": "Create a tag",
"description": "Creates a new tag for the authenticated user. Requires `tasks:write` scope.",
"operationId": "createTag",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["name"],
"properties": {
"name": { "type": "string", "minLength": 1, "maxLength": 50 },
"color": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$", "example": "#6B7280" }
}
}
}
}
},
"responses": {
"200": {
"description": "Tag created",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["tag"],
"properties": {
"tag": { "$ref": "#/components/schemas/Tag" }
}
}
}
}
},
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tags/{id}": {
"get": {
"tags": ["Tags"],
"summary": "Get a tag",
"description": "Returns a single tag by ID. Requires `tasks:read` scope.",
"operationId": "getTag",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": {
"description": "Tag details",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["tag"],
"properties": {
"tag": { "$ref": "#/components/schemas/Tag" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Tag not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"put": {
"tags": ["Tags"],
"summary": "Update a tag",
"description": "Updates a tag. Requires `tasks:write` scope.",
"operationId": "updateTag",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": { "type": "string", "minLength": 1, "maxLength": 50 },
"color": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" }
}
}
}
}
},
"responses": {
"200": {
"description": "Tag updated",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["tag"],
"properties": {
"tag": { "$ref": "#/components/schemas/Tag" }
}
}
}
}
},
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Tag not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"delete": {
"tags": ["Tags"],
"summary": "Delete a tag",
"description": "Deletes a tag. Requires `tasks:write` scope.",
"operationId": "deleteTag",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": { "description": "Tag deleted", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Tag not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tags/{id}/attach/{taskId}": {
"post": {
"tags": ["Tags"],
"summary": "Attach tag to task",
"description": "Attaches a tag to a task. Requires `tasks:write` scope.",
"operationId": "attachTagToTask",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Tag ID" },
{ "name": "taskId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Task ID" }
],
"responses": {
"200": { "description": "Tag attached", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Tag or task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tags/{id}/detach/{taskId}": {
"delete": {
"tags": ["Tags"],
"summary": "Detach tag from task",
"description": "Removes a tag from a task. Requires `tasks:write` scope.",
"operationId": "detachTagFromTask",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Tag ID" },
{ "name": "taskId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Task ID" }
],
"responses": {
"200": { "description": "Tag detached", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Tag or task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
}
}
}

View File

@@ -0,0 +1,459 @@
{
"paths": {
"/tasks": {
"get": {
"tags": ["Tasks"],
"summary": "List tasks",
"description": "Returns the authenticated user's tasks with optional filters. Supports status, priority, due date range, project, and cursor-based pagination. Requires `tasks:read` scope.",
"operationId": "listTasks",
"parameters": [
{ "name": "status", "in": "query", "schema": { "type": "string", "enum": ["todo", "in_progress", "done", "archived"] }, "description": "Filter by status" },
{ "name": "priority", "in": "query", "schema": { "type": "string", "enum": ["low", "medium", "high", "critical"] }, "description": "Filter by priority" },
{ "name": "project_id", "in": "query", "schema": { "type": "string", "format": "uuid" }, "description": "Filter by project" },
{ "name": "due_from", "in": "query", "schema": { "type": "string", "format": "date-time" }, "description": "Filter tasks due on or after" },
{ "name": "due_to", "in": "query", "schema": { "type": "string", "format": "date-time" }, "description": "Filter tasks due on or before" },
{ "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 200, "default": 50 } },
{ "name": "cursor", "in": "query", "schema": { "type": "string" }, "description": "Pagination cursor" }
],
"responses": {
"200": {
"description": "List of tasks",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["items", "page"],
"properties": {
"items": { "type": "array", "items": { "$ref": "#/components/schemas/Task" } },
"page": { "$ref": "#/components/schemas/PageInfo" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"post": {
"tags": ["Tasks"],
"summary": "Create a task",
"description": "Creates a new task for the authenticated user. Requires `tasks:write` scope.",
"operationId": "createTask",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["title"],
"properties": {
"title": { "type": "string", "minLength": 1, "maxLength": 500 },
"description": { "type": "string" },
"status": { "type": "string", "enum": ["todo", "in_progress", "done", "archived"], "default": "todo" },
"priority": { "type": "string", "enum": ["low", "medium", "high", "critical"], "default": "medium" },
"due_date": { "type": "string", "format": "date-time" },
"project_id": { "type": "string", "format": "uuid" },
"parent_id": { "type": "string", "format": "uuid" },
"sort_order": { "type": "integer" },
"recurrence_rule": { "type": "string" }
}
}
}
}
},
"responses": {
"200": {
"description": "Task created",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["task"],
"properties": {
"task": { "$ref": "#/components/schemas/Task" }
}
}
}
}
},
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tasks/{id}": {
"get": {
"tags": ["Tasks"],
"summary": "Get a task",
"description": "Returns a single task by ID. Requires `tasks:read` scope.",
"operationId": "getTask",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": {
"description": "Task details",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["task"],
"properties": {
"task": { "$ref": "#/components/schemas/Task" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"put": {
"tags": ["Tasks"],
"summary": "Update a task",
"description": "Updates a task's fields. Requires `tasks:write` scope.",
"operationId": "updateTask",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"title": { "type": "string", "minLength": 1, "maxLength": 500 },
"description": { "type": "string" },
"status": { "type": "string", "enum": ["todo", "in_progress", "done", "archived"] },
"priority": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
"due_date": { "type": "string", "format": "date-time" },
"project_id": { "type": "string", "format": "uuid", "nullable": true },
"sort_order": { "type": "integer" },
"recurrence_rule": { "type": "string", "nullable": true }
}
}
}
}
},
"responses": {
"200": {
"description": "Task updated",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["task"],
"properties": {
"task": { "$ref": "#/components/schemas/Task" }
}
}
}
}
},
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"delete": {
"tags": ["Tasks"],
"summary": "Delete a task",
"description": "Soft-deletes a task by default. Use `?permanent=true` for hard delete. Requires `tasks:write` scope.",
"operationId": "deleteTask",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } },
{ "name": "permanent", "in": "query", "schema": { "type": "boolean", "default": false }, "description": "If true, permanently delete (hard delete)" }
],
"responses": {
"200": { "description": "Task deleted", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tasks/{id}/complete": {
"post": {
"tags": ["Tasks"],
"summary": "Mark task complete",
"description": "Marks a task as done. Fails if blocked by incomplete dependencies. Requires `tasks:write` scope.",
"operationId": "markTaskComplete",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": {
"description": "Task marked complete",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["task"],
"properties": {
"task": { "$ref": "#/components/schemas/Task" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"409": { "description": "Blocked by incomplete dependencies", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tasks/{id}/uncomplete": {
"post": {
"tags": ["Tasks"],
"summary": "Mark task uncomplete",
"description": "Reverts a completed task to todo (or specified status). Requires `tasks:write` scope.",
"operationId": "markTaskUncomplete",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": { "type": "string", "enum": ["todo", "in_progress"], "default": "todo" }
}
}
}
}
},
"responses": {
"200": {
"description": "Task marked uncomplete",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["task"],
"properties": {
"task": { "$ref": "#/components/schemas/Task" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tasks/{id}/subtasks": {
"get": {
"tags": ["Tasks"],
"summary": "List subtasks",
"description": "Returns the subtasks of a task. Requires `tasks:read` scope.",
"operationId": "listTaskSubtasks",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": {
"description": "List of subtasks",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["items", "page"],
"properties": {
"items": { "type": "array", "items": { "$ref": "#/components/schemas/Task" } },
"page": { "$ref": "#/components/schemas/PageInfo" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tasks/{id}/dependencies": {
"get": {
"tags": ["Tasks"],
"summary": "List task blockers",
"description": "Returns tasks that block this task from being completed. Requires `tasks:read` scope.",
"operationId": "listTaskBlockers",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": {
"description": "List of blocking tasks",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["items", "page"],
"properties": {
"items": { "type": "array", "items": { "$ref": "#/components/schemas/Task" } },
"page": { "$ref": "#/components/schemas/PageInfo" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"post": {
"tags": ["Tasks"],
"summary": "Add dependency",
"description": "Adds a dependency: the specified task blocks this task. Requires `tasks:write` scope.",
"operationId": "addTaskDependency",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Task ID (blocked task)" }
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["blocks_task_id"],
"properties": {
"blocks_task_id": { "type": "string", "format": "uuid", "description": "Task that blocks this one" }
}
}
}
}
},
"responses": {
"200": { "description": "Dependency added", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"400": { "description": "Validation error (e.g. self-dependency)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"409": { "description": "Circular dependency detected", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tasks/{id}/dependencies/{blocksTaskId}": {
"delete": {
"tags": ["Tasks"],
"summary": "Remove dependency",
"description": "Removes a dependency. Requires `tasks:write` scope.",
"operationId": "removeTaskDependency",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Task ID (blocked task)" },
{ "name": "blocksTaskId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Blocker task ID" }
],
"responses": {
"200": { "description": "Dependency removed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tasks/{id}/reminders": {
"get": {
"tags": ["Tasks"],
"summary": "List task reminders",
"description": "Returns reminders for a task. Requires `tasks:read` scope.",
"operationId": "listTaskReminders",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": {
"description": "List of reminders",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["items", "page"],
"properties": {
"items": { "type": "array", "items": { "$ref": "#/components/schemas/TaskReminder" } },
"page": { "$ref": "#/components/schemas/PageInfo" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"post": {
"tags": ["Tasks"],
"summary": "Add task reminder",
"description": "Creates a reminder for a task. Requires `tasks:write` scope.",
"operationId": "addTaskReminder",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["type", "scheduled_at"],
"properties": {
"type": { "type": "string", "enum": ["push", "email", "webhook", "telegram", "nostr"] },
"config": { "type": "object", "additionalProperties": true },
"scheduled_at": { "type": "string", "format": "date-time" }
}
}
}
}
},
"responses": {
"200": {
"description": "Reminder created",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["reminder"],
"properties": {
"reminder": { "$ref": "#/components/schemas/TaskReminder" }
}
}
}
}
},
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/tasks/{id}/reminders/{reminderId}": {
"delete": {
"tags": ["Tasks"],
"summary": "Delete task reminder",
"description": "Deletes a reminder. Requires `tasks:write` scope.",
"operationId": "deleteTaskReminder",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Task ID" },
{ "name": "reminderId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" }, "description": "Reminder ID" }
],
"responses": {
"200": { "description": "Reminder deleted", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Task or reminder not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
}
}
}

View File

@@ -0,0 +1,96 @@
{
"paths": {
"/webhooks": {
"get": {
"tags": ["Webhooks"],
"summary": "List task webhooks",
"description": "Returns the authenticated user's task webhooks. Requires `tasks:read` scope.",
"operationId": "listTaskWebhooks",
"parameters": [
{ "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 200, "default": 50 } },
{ "name": "cursor", "in": "query", "schema": { "type": "string" }, "description": "Pagination cursor" }
],
"responses": {
"200": {
"description": "List of webhooks",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["items", "page"],
"properties": {
"items": { "type": "array", "items": { "$ref": "#/components/schemas/TaskWebhook" } },
"page": { "$ref": "#/components/schemas/PageInfo" }
}
}
}
}
},
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
},
"post": {
"tags": ["Webhooks"],
"summary": "Create task webhook",
"description": "Creates a webhook that receives task events (created, status_change, completion). Requires `tasks:write` scope.",
"operationId": "createTaskWebhook",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["url", "events"],
"properties": {
"url": { "type": "string", "format": "uri", "description": "Webhook endpoint URL" },
"events": {
"type": "array",
"items": { "type": "string", "enum": ["created", "status_change", "completion"] },
"description": "Events to subscribe to"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Webhook created",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["webhook"],
"properties": {
"webhook": { "$ref": "#/components/schemas/TaskWebhook" }
}
}
}
}
},
"400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
},
"/webhooks/{id}": {
"delete": {
"tags": ["Webhooks"],
"summary": "Delete task webhook",
"description": "Deletes a task webhook. Requires `tasks:write` scope.",
"operationId": "deleteTaskWebhook",
"parameters": [
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
],
"responses": {
"200": { "description": "Webhook deleted", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OkResponse" } } } },
"401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"403": { "description": "Insufficient scope", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
"404": { "description": "Webhook not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
}
}
}
}
}

View File

@@ -13,18 +13,24 @@ import (
)
type Handlers struct {
Auth *handlers.AuthHandler
User *handlers.UserHandler
Calendar *handlers.CalendarHandler
Sharing *handlers.SharingHandler
Event *handlers.EventHandler
Reminder *handlers.ReminderHandler
Attendee *handlers.AttendeeHandler
Contact *handlers.ContactHandler
Availability *handlers.AvailabilityHandler
Booking *handlers.BookingHandler
APIKey *handlers.APIKeyHandler
ICS *handlers.ICSHandler
Auth *handlers.AuthHandler
User *handlers.UserHandler
Calendar *handlers.CalendarHandler
Sharing *handlers.SharingHandler
Event *handlers.EventHandler
Reminder *handlers.ReminderHandler
Attendee *handlers.AttendeeHandler
Contact *handlers.ContactHandler
Availability *handlers.AvailabilityHandler
Booking *handlers.BookingHandler
APIKey *handlers.APIKeyHandler
ICS *handlers.ICSHandler
Task *handlers.TaskHandler
Project *handlers.ProjectHandler
Tag *handlers.TagHandler
TaskDependency *handlers.TaskDependencyHandler
TaskReminder *handlers.TaskReminderHandler
TaskWebhook *handlers.TaskWebhookHandler
}
func NewRouter(h Handlers, authMW *mw.AuthMiddleware, rateLimiter *mw.RateLimiter, cfg *config.Config) *chi.Mux {
@@ -152,6 +158,68 @@ func NewRouter(h Handlers, authMW *mw.AuthMiddleware, rateLimiter *mw.RateLimite
})
})
// Tasks
r.Route("/tasks", func(r chi.Router) {
r.With(mw.RequireScope("tasks", "read")).Get("/", h.Task.List)
r.With(mw.RequireScope("tasks", "write")).Post("/", h.Task.Create)
r.Route("/{id}", func(r chi.Router) {
r.With(mw.RequireScope("tasks", "read")).Get("/", h.Task.Get)
r.With(mw.RequireScope("tasks", "write")).Put("/", h.Task.Update)
r.With(mw.RequireScope("tasks", "write")).Delete("/", h.Task.Delete)
r.With(mw.RequireScope("tasks", "write")).Post("/complete", h.Task.MarkComplete)
r.With(mw.RequireScope("tasks", "write")).Post("/uncomplete", h.Task.MarkUncomplete)
r.With(mw.RequireScope("tasks", "read")).Get("/subtasks", h.Task.ListSubtasks)
r.Route("/dependencies", func(r chi.Router) {
r.With(mw.RequireScope("tasks", "read")).Get("/", h.TaskDependency.ListBlockers)
r.With(mw.RequireScope("tasks", "write")).Post("/", h.TaskDependency.Add)
r.With(mw.RequireScope("tasks", "write")).Delete("/{blocksTaskId}", h.TaskDependency.Remove)
})
r.Route("/reminders", func(r chi.Router) {
r.With(mw.RequireScope("tasks", "read")).Get("/", h.TaskReminder.List)
r.With(mw.RequireScope("tasks", "write")).Post("/", h.TaskReminder.Add)
r.With(mw.RequireScope("tasks", "write")).Delete("/{reminderId}", h.TaskReminder.Delete)
})
})
})
// Projects
r.Route("/projects", func(r chi.Router) {
r.With(mw.RequireScope("tasks", "read")).Get("/", h.Project.List)
r.With(mw.RequireScope("tasks", "write")).Post("/", h.Project.Create)
r.Route("/{id}", func(r chi.Router) {
r.With(mw.RequireScope("tasks", "read")).Get("/", h.Project.Get)
r.With(mw.RequireScope("tasks", "write")).Put("/", h.Project.Update)
r.With(mw.RequireScope("tasks", "write")).Delete("/", h.Project.Delete)
r.With(mw.RequireScope("tasks", "write")).Post("/share", h.Project.Share)
r.With(mw.RequireScope("tasks", "read")).Get("/members", h.Project.ListMembers)
})
})
// Tags
r.Route("/tags", func(r chi.Router) {
r.With(mw.RequireScope("tasks", "read")).Get("/", h.Tag.List)
r.With(mw.RequireScope("tasks", "write")).Post("/", h.Tag.Create)
r.Route("/{id}", func(r chi.Router) {
r.With(mw.RequireScope("tasks", "read")).Get("/", h.Tag.Get)
r.With(mw.RequireScope("tasks", "write")).Put("/", h.Tag.Update)
r.With(mw.RequireScope("tasks", "write")).Delete("/", h.Tag.Delete)
r.With(mw.RequireScope("tasks", "write")).Post("/attach/{taskId}", h.Tag.AttachToTask)
r.With(mw.RequireScope("tasks", "write")).Delete("/detach/{taskId}", h.Tag.DetachFromTask)
})
})
// Task Webhooks
r.Route("/webhooks", func(r chi.Router) {
r.With(mw.RequireScope("tasks", "read")).Get("/", h.TaskWebhook.List)
r.With(mw.RequireScope("tasks", "write")).Post("/", h.TaskWebhook.Create)
r.With(mw.RequireScope("tasks", "write")).Delete("/{id}", h.TaskWebhook.Delete)
})
// Availability
r.With(mw.RequireScope("availability", "read")).Get("/availability", h.Availability.Get)
})