// Package glossary derives consumer views from resolved configuration. package glossary import "gitea.maximumdirect.net/eric/audita/v3/internal/core/config" // Entry is the known glossary content and its collection-scoped identity. type Entry struct { Collection string `json:"-"` ID string `json:"id"` Name string `json:"name"` Category string `json:"category"` Description string `json:"description,omitempty"` Aliases []string `json:"aliases,omitempty"` Plural *string `json:"plural,omitempty"` } type identity struct{ collection, id string } // Select retains the first occurrence of each selected collection entry. func Select(collections map[string]config.GlossaryCollection, names []string) []Entry { seen := make(map[identity]struct{}) var selected []Entry for _, name := range names { for _, item := range collections[name].Entries { key := identity{collection: name, id: item.ID} if _, exists := seen[key]; exists { continue } seen[key] = struct{}{} entry := Entry{Collection: name, ID: item.ID, Name: item.Name, Category: item.Category, Description: item.Description, Aliases: append([]string(nil), item.Aliases...)} if item.Plural != nil { plural := *item.Plural entry.Plural = &plural } selected = append(selected, entry) } } return selected }