package bootstrap

import (
	connectorreaders "github.com/nexuscrm/db/pkg/connectorreaders"
	connector "github.com/pingcap-inc/nexuscrm-contract/pkg/connector"
)

// FieldMappingGroup represents a set of field mappings between two objects for
// an action type. Relocated verbatim to the contract package (pure DTO).
type FieldMappingGroup = connector.FieldMappingGroup

// FieldMappingDef represents a single source→target field mapping. Relocated
// verbatim to the contract package (pure DTO).
type FieldMappingDef = connector.FieldMappingDef

// The legacy field-mapping WRITE/INIT/VERIFY surface was relocated to
// internal/controlplane/packs (Wave 5). The READ surface (GetFieldMappings /
// GetFieldMappingSourceForTarget) was relocated to the neutral sibling
// github.com/nexuscrm/db/pkg/connectorreaders (PR2 Step 1) because it is SHARED
// with the automation runtime field-mapping applier (via the contract
// runtimeports.ConnectorFieldMappingReader port) and with the standard-action
// reader port. The thin func-value aliases below keep existing backend callers
// (ConnectorFieldMappingReaderImpl, StandardActionReaderImpl, the CP seam
// wiring) compiling unchanged.

// GetFieldMappings retrieves active field mappings for a given conversion.
// Used by BootstrapFieldMappingApplier during flow-driven recordCreate to
// copy source-record field values into a newly created target record.
var GetFieldMappings = connectorreaders.GetFieldMappings

// GetFieldMappingSourceForTarget returns the active source field that maps to
// a target field for a conversion-style mapping tuple. It shares the same owner
// precedence as GetFieldMappings so standard-action discovery and Flow runtime
// describe the same metadata fact.
var GetFieldMappingSourceForTarget = connectorreaders.GetFieldMappingSourceForTarget

// ApplyFieldMappings applies field mappings from a source record to a target
// SObject. Relocated verbatim to the contract package (pure transform).
var ApplyFieldMappings = connector.ApplyFieldMappings

// GetFieldMappingsByTargetContext returns every active row in
// _System_ObjectFieldMapping for (targetObject, actionType), preserving
// SourceObject on each row. Relocated verbatim to the contract package; this
// thin func-value alias keeps existing backend callers + bootstrap tests
// compiling unchanged.
var GetFieldMappingsByTargetContext = connectorreaders.GetFieldMappingsByTargetContext

// GetFieldMappingsByTarget returns every active row in
// _System_ObjectFieldMapping for (targetObject, actionType), preserving
// SourceObject on each row. Relocated verbatim to the contract package; this
// thin func-value alias keeps existing backend callers + bootstrap tests
// compiling unchanged.
var GetFieldMappingsByTarget = connectorreaders.GetFieldMappingsByTarget
