linear

package
v0.0.42 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const PlatformID = "linear"

PlatformID is the platform identifier used in SessionKey and ingest routing.

Variables

This section is empty.

Functions

func NewPlatform

func NewPlatform(cfg config.LinearConfig, mediaSvc *media.Service) (platform.Platform, error)

NewPlatform constructs a Linear platform from configuration. Persistent state (seen_issues.ndjson, seen_comments.ndjson) lives in ~/.openbee/.linear/.

Types

type Client

type Client interface {
	Viewer(ctx context.Context) (User, error)
	// IssuesInStates returns every issue whose state.name is in `states`,
	// carrying label `label`, and belonging to one of the given `projects`.
	// Empty `states` or `projects` is rejected by policy at the platform layer.
	// The returned slice contains all pages materialized in chronological
	// (createdAt-ascending) order.
	IssuesInStates(ctx context.Context, states []string, label string, projects []string) ([]Issue, error)
	CreateComment(ctx context.Context, issueID, body string, parentID *string) (Comment, error)
	// DownloadAsset fetches a uploads.linear.app asset using the workspace API
	// key in the Authorization header. Returns the body and the server-reported
	// Content-Type. A non-2xx response or body larger than maxBytes is returned
	// as an error. maxBytes <= 0 disables the size limit.
	DownloadAsset(ctx context.Context, url string, maxBytes int) (data []byte, contentType string, err error)
	// FileUpload runs Linear's fileUpload mutation and returns the presigned
	// upload target plus the asset URL to embed in a comment markdown.
	FileUpload(ctx context.Context, name, mime string, size int) (FileUploadTicket, error)
	// CreateReaction adds a reaction to the given target with the given emoji
	// shortcode (e.g. ":eyes:") and returns the new reaction's ID.
	CreateReaction(ctx context.Context, target ReactionTarget, emoji string) (string, error)
}

Client is the Linear GraphQL client surface used by the receiver and sender. Tests substitute a fake.

func NewClient

func NewClient(apiKey string) Client

NewClient returns a Client backed by Linear's GraphQL endpoint.

type Comment

type Comment struct {
	ID        string    `json:"id"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"createdAt"`
	User      User      `json:"user"`
	ParentID  *string   `json:"parentId"`
}

Comment is the subset of Linear's Comment type we care about.

type FileUploadTicket

type FileUploadTicket struct {
	AssetURL  string
	UploadURL string
	Headers   map[string]string
}

FileUploadTicket is the result of Linear's fileUpload mutation. AssetURL is embedded into a comment markdown after the bytes are PUT to UploadURL with the supplied Headers.

type Issue

type Issue struct {
	ID          string    `json:"id"`
	Identifier  string    `json:"identifier"` // e.g. "ENG-42"
	Title       string    `json:"title"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
	Team        Team      `json:"team"`
	Creator     User      `json:"creator"`
	Project     *Project  `json:"project,omitempty"` // nil when issue has no project
	Comments    []Comment `json:"-"`                 // unwrapped from comments.nodes
}

Issue is the subset of Linear's Issue type we care about.

type LinearPlatform

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

LinearPlatform implements platform.Platform.

func (*LinearPlatform) ID

func (p *LinearPlatform) ID() string

func (*LinearPlatform) Receiver

func (*LinearPlatform) Sender

type LinearReceiver

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

LinearReceiver polls Linear for issue/comment updates by workflow-state.

func (*LinearReceiver) Start

func (r *LinearReceiver) Start(ctx context.Context, dispatch func(platform.InboundMessage)) error

Start runs the polling loop until ctx is cancelled.

type LinearSender

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

LinearSender posts replies as Linear comments.

func (*LinearSender) Send

type Project

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

Project is the subset of Linear's Project type we care about.

type ReactionTarget

type ReactionTarget struct {
	CommentID string
	IssueID   string
}

ReactionTarget identifies what to react on. Exactly one of CommentID or IssueID must be non-empty; CommentID takes precedence when both are set.

type SeenSet

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

SeenSet persists a grow-only set of already-dispatched IDs to <dir>/<filename> as NDJSON (one ID per line). Add is append-only. Not safe for concurrent use; expected to be driven by a single goroutine.

func NewSeenSet

func NewSeenSet(dir, filename string) *SeenSet

NewSeenSet constructs a SeenSet that persists to <dir>/<filename>. Call Load before using Contains or Add.

func (*SeenSet) Add

func (s *SeenSet) Add(_ context.Context, ids []string) error

Add records ids as dispatched and appends only the previously-unseen IDs to the on-disk NDJSON file. Empty input and fully-duplicate input are no-ops. The in-memory set is updated only after the write succeeds, so a write failure leaves memory and disk in sync.

func (*SeenSet) Contains

func (s *SeenSet) Contains(id string) bool

Contains reports whether id has already been dispatched.

func (*SeenSet) Load

func (s *SeenSet) Load(_ context.Context) error

Load reads the persisted ID set from disk. A missing file silently yields an empty set. A trailing line without a newline is treated as crash debris and dropped.

type Team

type Team struct {
	Key string `json:"key"` // e.g. "ENG"
}

Team is the subset of Linear's Team type we care about.

type User

type User struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

User is the subset of Linear's User type we care about.

Jump to

Keyboard shortcuts

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