package controlplane

import (
	"database/sql"

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

// CONTROL-PLANE SEAM — control-plane imports bootstrap = ZERO (W5/S7).
//
// getActionSchema is the db-passing route to the shared bootstrap
// standard-action schema reader, used by the control-plane integration tests so
// the test does not import internal/bootstrap directly. The reader STAYS in
// internal/bootstrap (action_schema.go) because it is the standard-action READ
// surface exposed to the automation feature via the contract
// runtimeports.StandardActionReader port; only the write/seed side relocated to
// controlplane. The control-plane no longer references internal/bootstrap; the
// concrete reader is injected at the composition roots (CP integration-test
// wiring; bootstrap.GetActionSchema) via SetGetActionSchema — never defaulted
// here.
//
// Mandatory injection: any caller of getActionSchema MUST wire it first, or it
// is nil. (Currently consulted only by the CP integration tests.)
var getActionSchema func(*sql.DB, string) ([]seedrows.ActionSchemaRow, error)

// SetGetActionSchema injects the standard-action schema reader. Intended for the
// composition roots / CP integration-test wiring, which supply
// bootstrap.GetActionSchema so the concrete dependency is owned outside the
// control-plane.
func SetGetActionSchema(f func(*sql.DB, string) ([]seedrows.ActionSchemaRow, error)) {
	if f == nil {
		return
	}
	getActionSchema = f
}
