package runtimeports

import (
	"database/sql"

	seedrows "github.com/pingcap-inc/nexuscrm-contract/pkg/seedrows"
)

// StandardActionReader is the read-only port for the standard-action
// dispatcher's metadata reads against the verified _System_* substrate
// (_System_ActionSchema, _System_ActionFieldDefault, _System_ActionInputGuard,
// the internal-access-scope projection, and the legacy field-mapping
// source lookup).
//
// The concrete implementation (internal/bootstrap.StandardActionReaderImpl)
// binds a *sql.DB at construction and delegates each method to the canonical
// bootstrap reader function of the same name, so behavior is identical to
// calling the bootstrap function directly. The port exists so the standard-
// action service (internal/features/automation/standardaction) depends on this
// neutral interface instead of importing internal/bootstrap for these reads.
type StandardActionReader interface {
	// GetActionSchema returns every active input/output descriptor for a
	// standard-action Id.
	GetActionSchema(db *sql.DB, standardActionID string) ([]seedrows.ActionSchemaRow, error)

	// GetActionFieldDefaults returns the field-default rows for a standard
	// action.
	GetActionFieldDefaults(db *sql.DB, standardActionID string) ([]seedrows.ActionFieldDefaultRow, error)

	// GetActionInputGuards returns the input-guard rows for a standard action.
	GetActionInputGuards(db *sql.DB, standardActionID string) ([]seedrows.ActionInputGuardRow, error)

	// GetStandardActionInternalAccessScopes returns the runtime internal-access
	// scope projection consulted before invoking a standard-action flow.
	GetStandardActionInternalAccessScopes(db *sql.DB, standardActionID string) ([]seedrows.StandardActionInternalAccessScopeRow, error)

	// GetFieldMappingSourceForTarget returns the source field that feeds a given
	// target field for a (sourceObject, targetObject, actionType) conversion.
	GetFieldMappingSourceForTarget(db *sql.DB, sourceObject, targetObject, actionType, targetField string) (string, error)
}
