package layoutroutingidentitymappingv1

import routing "github.com/pingcap-inc/nexuscrm-contract/pkg/layoutroutingsecurityv1"

const (
	// CanonicalizationVersion is the v1 mapping-payload grammar and digest
	// domain. It is not a source-policy or authorization version.
	CanonicalizationVersion = "nexuscrm.layout-routing-identity-mapping-proposal/v1"

	// MaxProfileMappings and MaxRoleMappings bound one complete org proposal.
	MaxProfileMappings = routing.MaxProfileIdentities
	MaxRoleMappings    = routing.MaxRoleIdentities
	// MaxCanonicalProposalBytes prevents an oversized proposal from becoming a
	// distinct resource-policy surface from the eventual routing view.
	MaxCanonicalProposalBytes = routing.MaxCanonicalViewBytes
)

// ProfileMapping proposes the only permitted ProfileKey-to-local-ID pair for
// one complete stopped-migration input. It has no active/tombstone state.
type ProfileMapping struct {
	Key               routing.ProfileKey
	ResolvedProfileID string
}

// RoleMapping proposes the only permitted RoleKey-to-local-ID pair for one
// complete stopped-migration input. Role topology is intentionally excluded.
type RoleMapping struct {
	Key            routing.RoleKey
	ResolvedRoleID string
}

// Proposal is one complete typed Profile/Role key-to-local-ID bijection for
// an exact org. Profiles and Roles must be present (possibly empty) and input
// order is non-semantic; canonicalization sorts each typed dimension.
type Proposal struct {
	OrgID                   string
	CanonicalizationVersion string
	KeyGrammarVersion       string
	Profiles                []ProfileMapping
	Roles                   []RoleMapping
}
