package data_pipeline

import (
	"github.com/shiningrush/fastflow/pkg/entity"
	"github.com/shiningrush/fastflow/pkg/entity/run"
	data_pipeline_model "github.com/tidbcloud/dataflow-service-ng/app/models/data_pipeline"
	"github.com/tidbcloud/dataflow-service-ng/app/workflow"
	data_pipeline_action "github.com/tidbcloud/dataflow-service-ng/app/workflow/action/data_pipeline"
)

// GetEditDataPipelineDag applies a new desired revision to the stopped children.
// Edit owns the writes so a rejected value fails while the Pipeline is still
// pausable and editable, instead of surfacing later during Resume.
func GetEditDataPipelineDag(
	coordinator data_pipeline_model.LifecycleCoordinator,
) (*entity.Dag, []run.Action) {
	actions := []run.Action{
		data_pipeline_action.NewApplyChangefeedAction(coordinator),
		data_pipeline_action.NewApplyDestinationAction(coordinator),
		data_pipeline_action.NewFinishEditAction(coordinator),
	}
	return buildLinearDag(workflow.DagEditDataPipeline, actions)
}
