refactor(tasks)!: add task DTOs, enforce UUIDs for IDs

Amolith created

Introduces `Task` and `Source` data transfer objects (DTOs) for
representing task-related data, primarily for API responses.

Validation for `CreateTaskRequest` has been updated:
- `AreaID` validation now enforces `uuid4` format if the field is present.
- `GoalID` validation now enforces `uuid4` format if the field is present.

BREAKING CHANGE: The `AreaID` and `GoalID` fields in the `CreateTaskRequest`
must now be valid UUIDv4 strings if provided. Previously, these fields
might have accepted non-UUID strings or had less strict validation.
Clients sending requests to create tasks must ensure these IDs conform to
the UUIDv4 format to avoid validation errors.

Change summary

lunatask/tasks.go | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)

Detailed changes

lunatask/tasks.go 🔗

@@ -33,10 +33,35 @@ func NewClient(accessToken string) *Client {
 	}
 }
 
+// Source represents a task source like GitHub or other integrations
+type Source struct {
+	Source   string `json:"source"`
+	SourceID string `json:"source_id"`
+}
+
+// Task is only ever used in responses
+type Task struct {
+	ID             string   `json:"id,omitempty"`
+	AreaID         string   `json:"area_id,omitempty"`
+	GoalID         string   `json:"goal_id,omitempty"`
+	Status         string   `json:"status,omitempty"`
+	PreviousStatus string   `json:"previous_status,omitempty"`
+	Estimate       int      `json:"estimate,omitempty"`
+	Priority       int      `json:"priority,omitempty"`
+	Progress       int      `json:"progress,omitempty"`
+	Motivation     string   `json:"motivation,omitempty"`
+	Eisenhower     int      `json:"eisenhower,omitempty"`
+	Sources        []Source `json:"sources,omitempty"`
+	ScheduledOn    string   `json:"scheduled_on,omitempty"`
+	CompletedAt    string   `json:"completed_at,omitempty"`
+	CreatedAt      string   `json:"created_at,omitempty"`
+	UpdatedAt      string   `json:"updated_at,omitempty"`
+}
+
 // CreateTaskRequest represents the request to create a task in Lunatask
 type CreateTaskRequest struct {
-	AreaID      string `json:"area_id"`
-	GoalID      string `json:"goal_id,omitempty" validate:"omitempty"`
+	AreaID      string `json:"area_id" validate:"omitempty,uuid4"`
+	GoalID      string `json:"goal_id,omitempty" validate:"omitempty,uuid4"`
 	Name        string `json:"name" validate:"max=100"`
 	Note        string `json:"note,omitempty" validate:"omitempty"`
 	Status      string `json:"status,omitempty" validate:"omitempty,oneof=later next started waiting completed"`