package core import ( "errors" "regexp" "strings" ) var ErrNotFound = errors.New("not found") type Page[T any] struct { Items []T Cursor string } type PageReq struct { Limit int Cursor string } type Path string var pathSegment = regexp.MustCompile(`^[a-z0-9_]+$`) func (p Path) Valid() error { s := string(p) if s == "" { return errors.New("path is empty") } segments := strings.Split(s, ".") for _, seg := range segments { if seg == "" { return errors.New("path contains empty segment") } if !pathSegment.MatchString(seg) { return errors.New("path segment must match [a-z0-9_]+: " + seg) } } return nil } func (p Path) Parent() Path { s := string(p) i := strings.LastIndex(s, ".") if i < 0 { return "" } return Path(s[:i]) }