glossary

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidInput = errors.New("invalid input")
	ErrTermNotFound = errors.New("glossary term not found")
	ErrTermExists   = errors.New("glossary term already exists")
	ErrCircularRef  = errors.New("circular reference detected in term hierarchy")
)
View Source
var (
	ErrNotFound = errors.New("glossary term not found")
	ErrConflict = errors.New("glossary term with this name already exists")
)

Functions

This section is empty.

Types

type CreateTermInput

type CreateTermInput struct {
	Name         string                 `json:"name" validate:"required,min=1,max=255"`
	Definition   string                 `json:"definition" validate:"required,min=1"`
	Description  *string                `json:"description,omitempty"`
	ParentTermID *string                `json:"parent_term_id,omitempty"`
	Owners       []OwnerInput           `json:"owners" validate:"required,min=1,dive"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
	Tags         []string               `json:"tags,omitempty"`
}

type GlossaryTerm

type GlossaryTerm struct {
	ID           string                 `json:"id"`
	Name         string                 `json:"name"`
	Definition   string                 `json:"definition"`
	Description  *string                `json:"description,omitempty"`
	ParentTermID *string                `json:"parent_term_id,omitempty"`
	Owners       []Owner                `json:"owners"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
	Tags         []string               `json:"tags,omitempty"`
	CreatedAt    time.Time              `json:"created_at"`
	UpdatedAt    time.Time              `json:"updated_at"`
	DeletedAt    *time.Time             `json:"deleted_at,omitempty"`
}

type ListResult

type ListResult struct {
	Terms []*GlossaryTerm `json:"terms"`
	Total int             `json:"total"`
}

type MetricsClient

type MetricsClient interface {
	Count(name string, value int64, tags ...string)
	Timing(name string, value time.Duration, tags ...string)
}

type Owner

type Owner struct {
	ID             string  `json:"id"`
	Username       *string `json:"username,omitempty"` // Only for user owners
	Name           string  `json:"name"`
	Type           string  `json:"type"` // "user" or "team"
	Email          *string `json:"email,omitempty"`
	ProfilePicture *string `json:"profile_picture,omitempty"`
}

type OwnerInput

type OwnerInput struct {
	ID   string `json:"id" validate:"required"`
	Type string `json:"type" validate:"required,oneof=user team"`
}

type PostgresRepository

type PostgresRepository struct {
	// contains filtered or unexported fields
}

func NewPostgresRepository

func NewPostgresRepository(db *pgxpool.Pool, recorder metrics.Recorder) *PostgresRepository

func (*PostgresRepository) Create

func (r *PostgresRepository) Create(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error

func (*PostgresRepository) Get

func (*PostgresRepository) GetChildren

func (r *PostgresRepository) GetChildren(ctx context.Context, parentID string) ([]*GlossaryTerm, error)

func (*PostgresRepository) List

func (r *PostgresRepository) List(ctx context.Context, offset, limit int) (*ListResult, error)

func (*PostgresRepository) Search

func (r *PostgresRepository) Search(ctx context.Context, filter SearchFilter) (*ListResult, error)

func (*PostgresRepository) Update

func (r *PostgresRepository) Update(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error

type Repository

type Repository interface {
	Create(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error
	Get(ctx context.Context, id string) (*GlossaryTerm, error)
	Update(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error
	List(ctx context.Context, offset, limit int) (*ListResult, error)
	Search(ctx context.Context, filter SearchFilter) (*ListResult, error)
	GetChildren(ctx context.Context, parentID string) ([]*GlossaryTerm, error)
}

type SearchFilter

type SearchFilter struct {
	Query        string   `json:"query,omitempty"`
	ParentTermID *string  `json:"parent_term_id,omitempty"`
	OwnerIDs     []string `json:"owner_ids,omitempty"`
	Limit        int      `json:"limit,omitempty" validate:"omitempty,gte=0,lte=100"`
	Offset       int      `json:"offset,omitempty" validate:"omitempty,gte=0"`
}

type Service

type Service interface {
	Create(ctx context.Context, input CreateTermInput) (*GlossaryTerm, error)
	Get(ctx context.Context, id string) (*GlossaryTerm, error)
	Update(ctx context.Context, id string, input UpdateTermInput) (*GlossaryTerm, error)
	Delete(ctx context.Context, id string) error
	List(ctx context.Context, offset, limit int) (*ListResult, error)
	Search(ctx context.Context, filter SearchFilter) (*ListResult, error)
	GetChildren(ctx context.Context, parentID string) ([]*GlossaryTerm, error)
	GetAncestors(ctx context.Context, termID string) ([]*GlossaryTerm, error)
}

func NewService

func NewService(repo Repository, opts ...ServiceOption) Service

type ServiceOption

type ServiceOption func(*service)

func WithMetrics

func WithMetrics(metrics MetricsClient) ServiceOption

type UpdateTermInput

type UpdateTermInput struct {
	Name         *string                `json:"name,omitempty" validate:"omitempty,min=1,max=255"`
	Definition   *string                `json:"definition,omitempty" validate:"omitempty,min=1"`
	Description  *string                `json:"description,omitempty"`
	ParentTermID *string                `json:"parent_term_id,omitempty"`
	Owners       []OwnerInput           `json:"owners,omitempty" validate:"omitempty,min=1,dive"`
	Metadata     map[string]interface{} `json:"metadata,omitempty"`
	Tags         []string               `json:"tags,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL