package automation

import (
	"github.com/nexuscrm/kernel/pkg/ports"
	"github.com/nexuscrm/metadata"
	"github.com/nexuscrm/kernel/pkg/logging"
)

func testEmailCompatibilityFlowActionCallRegistrations() []FlowActionCallRegistration {
	return []FlowActionCallRegistration{
		LegacySendEmailAliasFlowActionCallRegistration("emailSimple", "crm:automation/email-simple"),
		DisabledWorkflowAlertFlowActionCallRegistration("emailAlert", "crm:automation/email-alert-disabled"),
	}
}

func testRuntimeFlowActionCallRegistrations() []FlowActionCallRegistration {
	registrations := PlatformFlowActionCallRegistrations()
	registrations = append(registrations, testEmailCompatibilityFlowActionCallRegistrations()...)
	return registrations
}

func newFlowExecutorWithPlatformActionCalls(
	metadataService *metadata.MetadataService,
	actions *ActionService,
	interviews *FlowInterviewService,
	persistence PersistenceProvider,
	query ports.QueryService,
	fieldMappings FieldMappingApplier,
	logger *logging.Logger,
	opts ...Option,
) *FlowExecutor {
	allOpts := []Option{WithFlowActionCalls(testRuntimeFlowActionCallRegistrations()...)}
	allOpts = append(allOpts, opts...)
	return NewFlowExecutor(
		metadataService,
		actions,
		interviews,
		persistence,
		query,
		fieldMappings,
		logger,
		allOpts...,
	)
}
