Help us shape the future of Go! Take the 2026 Go Developer Survey

names

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package names provides name resolution for projects, people, and todolists. It implements fuzzy matching with the following priority: 1. Numeric ID passthrough 2. Exact match (case-sensitive) 3. Case-insensitive match 4. Partial match (contains)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Person

type Person struct {
	ID             int64  `json:"id"`
	AttachableSGID string `json:"attachable_sgid,omitempty"`
	Name           string `json:"name"`
	Email          string `json:"email_address"`
	PersonableType string `json:"personable_type,omitempty"` // e.g., "User", "Client"
}

Person represents a Basecamp person for name resolution.

func ResolveAmong added in v0.14.0

func ResolveAmong(input string, people []Person) (*Person, error)

ResolveAmong resolves a fuzzy @Name mention against a fixed set of people, such as the people in a Ping, where only they can be addressed. It applies the same exact, case-insensitive, then partial matching as everywhere else, and fails with the same not-found and ambiguous errors.

type Project

type Project struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

Project represents a Basecamp project for name resolution.

type ProjectScope added in v0.12.0

type ProjectScope func(context.Context) (int64, error)

ProjectScope yields the project whose agents an @mention may reach. The resolver calls it only when the pingable set cannot answer on its own, so a mention of a pingable person never pays for resolving the project. A nil scope, or one that yields 0, means no project is in scope.

func ParseProjectScope added in v0.12.0

func ParseProjectScope(projectID string) ProjectScope

ParseProjectScope returns a scope for a project given by numeric ID, or nil when the value is empty or not an ID.

type Resolver

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

Resolver resolves names to IDs for projects, people, and todolists.

func NewResolver

func NewResolver(sdkClient *basecamp.Client, authMgr *auth.Manager, accountID string) *Resolver

NewResolver creates a new name resolver. The accountID is used to configure the SDK client for account-scoped API calls.

func (*Resolver) ClearCache

func (r *Resolver) ClearCache()

ClearCache clears the session cache.

func (*Resolver) GetPeople

func (r *Resolver) GetPeople(ctx context.Context) ([]Person, error)

GetPeople returns all people (useful for pickers).

func (*Resolver) GetProjects

func (r *Resolver) GetProjects(ctx context.Context) ([]Project, error)

GetProjects returns all projects (useful for pickers).

func (*Resolver) GetTodolists

func (r *Resolver) GetTodolists(ctx context.Context, projectID string) ([]Todolist, error)

GetTodolists returns all todolists for a project (useful for pickers).

func (*Resolver) ProjectName added in v0.14.0

func (r *Resolver) ProjectName(ctx context.Context, id int64) (string, error)

ProjectName returns the name of the project with the given ID, or "" when the project is not found or not visible. It reads the session's project list when one was already fetched, and otherwise that one project. The list holds only active projects, so a miss there still reads the project itself.

func (*Resolver) ResolveMentionByID added in v0.12.0

func (r *Resolver) ResolveMentionByID(ctx context.Context, id int64) (*Person, error)

ResolveMentionByID resolves a [@Name](person:ID) mention. A pingable person resolves from the cached pingable set. Any other ID is looked up directly and accepted only if it is an agent, the one kind of principal the pingable set may leave out: it holds only the agents the caller can reach.

func (*Resolver) ResolveMentionByName added in v0.12.0

func (r *Resolver) ResolveMentionByName(ctx context.Context, input string, scope ProjectScope) (*Person, error)

ResolveMentionByName resolves a fuzzy @Name mention.

People resolve against the pingable set, exactly as ResolvePersonByName does. That set holds only the agents the caller can reach, not every agent on a project; when scope names a project, the agents on that project are candidates too. Only agents are drawn from the project: a person who is not pingable stays unmentionable.

A name that equals an agent's (ignoring case) wins over a person whose name merely contains it, so "@Quincy" reaches the agent Quincy rather than a pingable "Quincy Jones". Otherwise people keep precedence, and an agent is matched by partial name only when no person matches at all.

func (*Resolver) ResolvePerson

func (r *Resolver) ResolvePerson(ctx context.Context, input string) (string, string, error)

ResolvePerson resolves a person name, email, or ID to an ID. Special case: "me" resolves to the current user. Returns the ID and the person's name for display.

func (*Resolver) ResolvePersonByID added in v0.7.0

func (r *Resolver) ResolvePersonByID(ctx context.Context, id int64) (*Person, error)

ResolvePersonByID looks up a person by numeric ID in the pingable set. Returns the Person record including AttachableSGID. Returns not-found if the person is not in the pingable set.

func (*Resolver) ResolvePersonByName added in v0.7.0

func (r *Resolver) ResolvePersonByName(ctx context.Context, input string) (*Person, error)

ResolvePersonByName resolves a person name to a full Person record including AttachableSGID. Resolves against the pingable set only — mentions require the target to be pingable.

func (*Resolver) ResolvePingable added in v0.14.0

func (r *Resolver) ResolvePingable(ctx context.Context, input string) (*Person, error)

ResolvePingable resolves a person's ID, email address or name among the people the caller can ping, the only people a Ping can include. A name that matches more than one of them is ambiguous.

func (*Resolver) ResolveProject

func (r *Resolver) ResolveProject(ctx context.Context, input string) (string, string, error)

ResolveProject resolves a project name or ID to an ID. Returns the ID and the project name for display. For a numeric ID the name is "" unless the session already listed projects; see ProjectName.

func (*Resolver) ResolveTodolist

func (r *Resolver) ResolveTodolist(ctx context.Context, input, projectID string) (string, string, error)

ResolveTodolist resolves a todolist name or ID within a project. Returns the ID and the todolist name for display.

func (*Resolver) SetAccountID

func (r *Resolver) SetAccountID(accountID string)

SetAccountID updates the account ID used by the resolver. This clears the cache since cached data is account-specific.

type ScopeError added in v0.12.0

type ScopeError struct{ Err error }

ScopeError reports that a mention's project scope could not be resolved. It is distinct from a person lookup miss, which callers may downgrade.

func (*ScopeError) Error added in v0.12.0

func (e *ScopeError) Error() string

func (*ScopeError) Unwrap added in v0.12.0

func (e *ScopeError) Unwrap() error

type Todolist

type Todolist struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

Todolist represents a Basecamp todolist for name resolution.

Jump to

Keyboard shortcuts

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