package groups

import (
	"nadir/internal/rbac"

	"github.com/danielgtaylor/huma/v2"
)

const ModuleID = "groups"

type Module struct{}

func New() *Module { return &Module{} }

func (m *Module) ID() string   { return ModuleID }

// Permissions: read to list/inspect groups; write to create; root to delete
// (irreversible). Group membership lives in the users module.
func (m *Module) Permissions() []rbac.Permission {
	return []rbac.Permission{rbac.Read, rbac.Write, rbac.Root}
}

func (m *Module) Register(api huma.API) {
	registerGroups(api)
}

func op(permission string) map[string]any {
	return map[string]any{"module": ModuleID, "permission": permission}
}
