package appidentitykeydeclarationv1

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

const (
	// ProfileComponentKind declares one positive App source fact for a typed
	// ProfileKey. It is distinct from RoleComponentKind so the declaration type
	// is carried by immutable component identity, not a behavior enum.
	ProfileComponentKind = "io.nexuscrm.profile-key-declaration.v1"
	// RoleComponentKind declares one positive App source fact for a typed
	// RoleKey.
	RoleComponentKind = "io.nexuscrm.role-key-declaration.v1"

	// ComponentFormatVersion is the only descriptor format accepted by v1.
	ComponentFormatVersion uint32 = 1
	// BehaviorSchemaVersion is the closed canonical behavior schema.
	BehaviorSchemaVersion = "nexuscrm.app-identity-key-declaration/v1"
	// DefinitionVersion is fixed because a v1 declaration is a positive source
	// fact, not a mutable key lifecycle or revision lineage.
	DefinitionVersion = "1"
)

// Behavior is the closed canonical content of a v1 identity-key declaration.
// NamespaceID and LocalKey intentionally remain descriptor facts.
type Behavior struct {
	SchemaVersion string
}

// ProfileDeclaration is one typed positive ProfileKey declaration extracted
// from a structurally verified App package.
type ProfileDeclaration struct {
	AppID                  string
	AppReleaseDigest       string
	Key                    layoutroutingsecurityv1.ProfileKey
	DeclarationComponentID string
	BehaviorDigest         string
}

// RoleDeclaration is one typed positive RoleKey declaration extracted from a
// structurally verified App package.
type RoleDeclaration struct {
	AppID                  string
	AppReleaseDigest       string
	Key                    layoutroutingsecurityv1.RoleKey
	DeclarationComponentID string
	BehaviorDigest         string
}

// Declarations retains the canonical MetadataBundle component order within
// each typed declaration collection. Both slices are always present in a
// successful result, including when no declarations of that type exist.
type Declarations struct {
	Profiles []ProfileDeclaration
	Roles    []RoleDeclaration
}
