package calendar

import "time"

// SnapshotVisitor consumes one repeatable-read view of accepted Runs and
// active Schedule sources. Runs is called exactly once before Source; Source
// is then called once per row so callers can stop without materializing every
// source in the workspace.
type SnapshotVisitor struct {
	Runs   func([]Run) error
	Source func(ScheduleSource) error
}

// Run is the narrow calendar projection of an accepted Workflow Invocation
// and its current Run state.
type Run struct {
	InvocationID       string
	RunID              string
	PlanID             string
	PlanVersionID      string
	WorkflowName       string
	PlanKey            string
	PlanDisplayName    string
	BindingID          string
	BindingKey         string
	BindingDisplayName string
	BindingRevisionID  string
	BindingSourceID    string
	SourceKind         string
	OccurrenceKey      string
	OccursAt           time.Time
	Status             string
	QueuedAt           time.Time
	StartedAt          *time.Time
	CompletedAt        *time.Time
	CanceledAt         *time.Time
}

// ScheduleSource is the current immutable Schedule revision plus its mutable
// earliest-unaccepted occurrence cursor.
type ScheduleSource struct {
	ID                string
	BindingID         string
	BindingRevisionID string
	Activation        int64
	NextOccurrenceAt  time.Time
	PlanID            string
	PlanVersionID     string
	// SourceJSON excludes inputPolicy and schedule inputs, which are not
	// needed to project occurrence times and may contain large payloads.
	SourceJSON         []byte
	BindingKey         string
	BindingDisplayName string
	PlanKey            string
	PlanDisplayName    string
}

type ListSnapshotParams struct {
	WorkspaceID string
	From        time.Time
	To          time.Time
	RunLimit    int
}
