package dto

import "github.com/tidbcloud/AgentTeam/internal/schedule/manage"

// ScheduleMutationRequest creates or updates a browser-facing schedule.
type ScheduleMutationRequest struct {
	Name                  string                       `json:"name"`
	Source                manage.SourceInput           `json:"source"`
	Target                manage.TargetInput           `json:"target"`
	MessageTemplate       string                       `json:"messageTemplate"`
	Mentions              []MessageMentionHint         `json:"mentions,omitempty"`
	AlsoStartThread       bool                         `json:"alsoStartThread,omitempty"`
	HumanNotificationMode manage.HumanNotificationMode `json:"humanNotificationMode,omitempty"`
}

// ScheduleValidateRequest validates a schedule mutation, optionally against an existing schedule.
type ScheduleValidateRequest struct {
	ScheduleID string `json:"scheduleId"`
	// TriggerID is accepted as a legacy browser payload alias while callers migrate.
	TriggerID string `json:"triggerId,omitempty"`
	ScheduleMutationRequest
}

func (request ScheduleValidateRequest) ExistingID() string {
	if request.ScheduleID != "" {
		return request.ScheduleID
	}
	return request.TriggerID
}

// ScheduleListResponse returns schedule definitions.
type ScheduleListResponse []manage.ScheduleView

// SchedulePageResponse returns one cursor page of schedule definitions.
type SchedulePageResponse struct {
	Schedules  []manage.ScheduleView `json:"schedules"`
	Limit      int                   `json:"limit"`
	Cursor     string                `json:"cursor,omitempty"`
	HasMore    bool                  `json:"hasMore"`
	NextCursor string                `json:"nextCursor,omitempty"`
}

// ScheduleRunListResponse returns schedule automation run history.
type ScheduleRunListResponse []manage.AutomationRunView

// ScheduleDeleteResponse reports a deleted schedule.
type ScheduleDeleteResponse struct {
	Deleted bool `json:"deleted"`
}
