- 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
243 lines
7.9 KiB
Go
243 lines
7.9 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type User struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Email string `json:"email"`
|
|
Timezone string `json:"timezone"`
|
|
WeekStartDay int `json:"week_start_day"`
|
|
DateFormat string `json:"date_format"`
|
|
TimeFormat string `json:"time_format"`
|
|
DefaultEventDurationMinutes int `json:"default_event_duration_minutes"`
|
|
DefaultReminderMinutes int `json:"default_reminder_minutes"`
|
|
ShowWeekends bool `json:"show_weekends"`
|
|
WorkingHoursStart string `json:"working_hours_start"`
|
|
WorkingHoursEnd string `json:"working_hours_end"`
|
|
NotificationsEmail bool `json:"notifications_email"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type Calendar struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
Color string `json:"color"`
|
|
IsPublic bool `json:"is_public"`
|
|
CountForAvailability bool `json:"count_for_availability"`
|
|
DefaultReminderMinutes *int `json:"default_reminder_minutes,omitempty"`
|
|
SortOrder int `json:"sort_order"`
|
|
ICalURL string `json:"ical_url,omitempty"`
|
|
AvailabilityURL string `json:"availability_url,omitempty"`
|
|
Role string `json:"role,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type Event struct {
|
|
ID uuid.UUID `json:"id"`
|
|
CalendarID uuid.UUID `json:"calendar_id"`
|
|
Title string `json:"title"`
|
|
Description *string `json:"description"`
|
|
Location *string `json:"location"`
|
|
StartTime time.Time `json:"start_time"`
|
|
EndTime time.Time `json:"end_time"`
|
|
Timezone string `json:"timezone"`
|
|
AllDay bool `json:"all_day"`
|
|
RecurrenceRule *string `json:"recurrence_rule"`
|
|
IsOccurrence bool `json:"is_occurrence,omitempty"`
|
|
OccurrenceStartTime *time.Time `json:"occurrence_start_time,omitempty"`
|
|
OccurrenceEndTime *time.Time `json:"occurrence_end_time,omitempty"`
|
|
CreatedBy uuid.UUID `json:"created_by"`
|
|
UpdatedBy uuid.UUID `json:"updated_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Reminders []Reminder `json:"reminders"`
|
|
Attendees []Attendee `json:"attendees"`
|
|
Tags []string `json:"tags"`
|
|
Attachments []Attachment `json:"attachments"`
|
|
}
|
|
|
|
type Reminder struct {
|
|
ID uuid.UUID `json:"id"`
|
|
MinutesBefore int32 `json:"minutes_before"`
|
|
}
|
|
|
|
type Attendee struct {
|
|
ID uuid.UUID `json:"id"`
|
|
UserID *uuid.UUID `json:"user_id"`
|
|
Email *string `json:"email"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type Attachment struct {
|
|
ID uuid.UUID `json:"id"`
|
|
FileURL string `json:"file_url"`
|
|
}
|
|
|
|
type Task struct {
|
|
ID uuid.UUID `json:"id"`
|
|
OwnerID uuid.UUID `json:"owner_id"`
|
|
Title string `json:"title"`
|
|
Description *string `json:"description"`
|
|
Status string `json:"status"`
|
|
Priority string `json:"priority"`
|
|
DueDate *time.Time `json:"due_date"`
|
|
CompletedAt *time.Time `json:"completed_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
ProjectID *uuid.UUID `json:"project_id"`
|
|
ParentID *uuid.UUID `json:"parent_id"`
|
|
SortOrder int `json:"sort_order"`
|
|
RecurrenceRule *string `json:"recurrence_rule"`
|
|
Subtasks []Task `json:"subtasks,omitempty"`
|
|
Tags []Tag `json:"tags,omitempty"`
|
|
CompletionPercentage *int `json:"completion_percentage,omitempty"`
|
|
}
|
|
|
|
type Project struct {
|
|
ID uuid.UUID `json:"id"`
|
|
OwnerID uuid.UUID `json:"owner_id"`
|
|
Name string `json:"name"`
|
|
Color string `json:"color"`
|
|
IsShared bool `json:"is_shared"`
|
|
Deadline *time.Time `json:"deadline"`
|
|
SortOrder int `json:"sort_order"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type ProjectMember struct {
|
|
UserID uuid.UUID `json:"user_id"`
|
|
Email string `json:"email"`
|
|
Role string `json:"role"`
|
|
}
|
|
|
|
type TaskWebhook struct {
|
|
ID uuid.UUID `json:"id"`
|
|
OwnerID uuid.UUID `json:"owner_id"`
|
|
URL string `json:"url"`
|
|
Events []string `json:"events"`
|
|
Secret *string `json:"secret,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type TaskReminder struct {
|
|
ID uuid.UUID `json:"id"`
|
|
TaskID uuid.UUID `json:"task_id"`
|
|
Type string `json:"type"`
|
|
Config map[string]interface{} `json:"config"`
|
|
ScheduledAt time.Time `json:"scheduled_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type Tag struct {
|
|
ID uuid.UUID `json:"id"`
|
|
OwnerID uuid.UUID `json:"owner_id"`
|
|
Name string `json:"name"`
|
|
Color string `json:"color"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type Contact struct {
|
|
ID uuid.UUID `json:"id"`
|
|
FirstName *string `json:"first_name"`
|
|
LastName *string `json:"last_name"`
|
|
Email *string `json:"email"`
|
|
Phone *string `json:"phone"`
|
|
Company *string `json:"company"`
|
|
Notes *string `json:"notes"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type APIKeyResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Name string `json:"name"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
RevokedAt *time.Time `json:"revoked_at"`
|
|
Token string `json:"token,omitempty"`
|
|
}
|
|
|
|
type CalendarMember struct {
|
|
UserID uuid.UUID `json:"user_id"`
|
|
Email string `json:"email"`
|
|
Role string `json:"role"`
|
|
}
|
|
|
|
type BusyBlock struct {
|
|
Start time.Time `json:"start"`
|
|
End time.Time `json:"end"`
|
|
EventID uuid.UUID `json:"event_id"`
|
|
}
|
|
|
|
type AvailabilityResponse struct {
|
|
CalendarID uuid.UUID `json:"calendar_id"`
|
|
RangeStart time.Time `json:"range_start"`
|
|
RangeEnd time.Time `json:"range_end"`
|
|
Busy []BusyBlock `json:"busy"`
|
|
}
|
|
|
|
type BookingLink struct {
|
|
Token string `json:"token"`
|
|
PublicURL string `json:"public_url,omitempty"`
|
|
Settings BookingConfig `json:"settings"`
|
|
}
|
|
|
|
type BookingConfig struct {
|
|
DurationMinutes int `json:"duration_minutes"`
|
|
BufferMinutes int `json:"buffer_minutes"`
|
|
Timezone string `json:"timezone"`
|
|
WorkingHours map[string][]Slot `json:"working_hours"`
|
|
Active bool `json:"active"`
|
|
}
|
|
|
|
type Slot struct {
|
|
Start string `json:"start"`
|
|
End string `json:"end"`
|
|
}
|
|
|
|
type BookingAvailability struct {
|
|
Token string `json:"token"`
|
|
Timezone string `json:"timezone"`
|
|
DurationMinutes int `json:"duration_minutes"`
|
|
Slots []TimeSlot `json:"slots"`
|
|
}
|
|
|
|
type TimeSlot struct {
|
|
Start time.Time `json:"start"`
|
|
End time.Time `json:"end"`
|
|
}
|
|
|
|
type PageInfo struct {
|
|
Limit int `json:"limit"`
|
|
NextCursor *string `json:"next_cursor"`
|
|
}
|
|
|
|
type ListResponse struct {
|
|
Items interface{} `json:"items"`
|
|
Page PageInfo `json:"page"`
|
|
}
|
|
|
|
type AuthTokens struct {
|
|
User User `json:"user"`
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
}
|
|
|
|
type TokenPair struct {
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
}
|
|
|
|
type AuditEntry struct {
|
|
EntityType string `json:"entity_type"`
|
|
EntityID uuid.UUID `json:"entity_id"`
|
|
Action string `json:"action"`
|
|
UserID uuid.UUID `json:"user_id"`
|
|
}
|