package store import ( "context" "chat-switchboard/models" ) // WorkflowStore manages workflow definitions, stages, and version snapshots. type WorkflowStore interface { // Workflow CRUD Create(ctx context.Context, w *models.Workflow) error GetByID(ctx context.Context, id string) (*models.Workflow, error) GetBySlug(ctx context.Context, teamID *string, slug string) (*models.Workflow, error) Update(ctx context.Context, id string, patch models.WorkflowPatch) error Delete(ctx context.Context, id string) error ListForTeam(ctx context.Context, teamID string) ([]models.Workflow, error) ListGlobal(ctx context.Context) ([]models.Workflow, error) // Stage CRUD CreateStage(ctx context.Context, s *models.WorkflowStage) error ListStages(ctx context.Context, workflowID string) ([]models.WorkflowStage, error) UpdateStage(ctx context.Context, s *models.WorkflowStage) error DeleteStage(ctx context.Context, id string) error ReorderStages(ctx context.Context, workflowID string, orderedIDs []string) error // Versioning Publish(ctx context.Context, v *models.WorkflowVersion) error GetVersion(ctx context.Context, workflowID string, versionNumber int) (*models.WorkflowVersion, error) GetLatestVersion(ctx context.Context, workflowID string) (*models.WorkflowVersion, error) // ── Assignments (v0.29.0-cs3) ── // CreateAssignment inserts a workflow_assignments row. CreateAssignment(ctx context.Context, a *WorkflowAssignment) error // ListAssignmentsForTeam returns assignments for a team filtered by status. ListAssignmentsForTeam(ctx context.Context, teamID, status string) ([]WorkflowAssignment, error) // ListAssignmentsMine returns claimed + unassigned assignments visible to a user. ListAssignmentsMine(ctx context.Context, userID string) ([]WorkflowAssignment, error) // ClaimAssignment sets assigned_to and status='claimed' on an unassigned row. // Returns rows affected (0 = already claimed or not found). ClaimAssignment(ctx context.Context, assignmentID, userID string) (int64, error) // CompleteAssignment sets status='completed' on a claimed row. // Returns rows affected (0 = not claimed or not found). CompleteAssignment(ctx context.Context, assignmentID string) (int64, error) // GetAssignmentChannelID returns the channel_id for an assignment. GetAssignmentChannelID(ctx context.Context, assignmentID string) (string, error) // TryRoundRobin finds the least-recently-assigned team member and claims. // Returns the assigned user ID, or "" if no members available. TryRoundRobin(ctx context.Context, teamID, assignmentID string) (string, error) }