github

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implements the pullrequest.PullRequestRepository interface

func NewAdapter

func NewAdapter(token string) *Adapter

NewAdapter creates a new GitHub adapter

func NewAdapterWithURL

func NewAdapterWithURL(baseURL string) *Adapter

NewAdapterWithURL creates a new GitHub adapter with a custom base URL (for testing)

func (*Adapter) AuthenticatedUser

func (a *Adapter) AuthenticatedUser() string

AuthenticatedUser returns the GitHub login of the authenticated user. Used by the application layer (e.g. notification handler, use case) to filter self-authored activities when deciding what to notify about.

func (*Adapter) FetchActivities

func (a *Adapter) FetchActivities(prs []*pullrequest.PullRequest, since time.Time) (map[string]pullrequest.PRActivityData, error)

FetchActivities fetches activity/enrichment facts for PRs since the given time using batched GraphQL queries.

func (*Adapter) FetchPRStatus

func (a *Adapter) FetchPRStatus(owner, repo string, number int) (pullrequest.PRStatus, error)

FetchPRStatus fetches the current status of a specific PR (open, merged, closed). Uses a lightweight GraphQL query to check only the PR state.

func (*Adapter) FetchRequestedReviews

func (a *Adapter) FetchRequestedReviews() ([]*pullrequest.PullRequest, error)

FetchRequestedReviews fetches PRs where the user is requested to review or has reviewed Note: GitHub search doesn't support OR operator, so we fetch both separately and deduplicate

func (*Adapter) FetchUserCreated

func (a *Adapter) FetchUserCreated() ([]*pullrequest.PullRequest, error)

FetchUserCreated fetches PRs created by the user

type AuthTransport

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

AuthTransport adds authentication headers to requests

func (*AuthTransport) RoundTrip

func (t *AuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper

type BatchedTimelineResponse

type BatchedTimelineResponse struct {
	Data   map[string]interface{} `json:"data"`
	Errors []GraphQLError         `json:"errors"`
}

BatchedTimelineResponse represents the response for batched timeline queries using aliases

type Client

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

Client handles HTTP communication with GitHub API

func NewClient

func NewClient(token string) *Client

NewClient creates a new GitHub API client

func NewClientWithURL

func NewClientWithURL(token string, baseURL string) *Client

NewClientWithURL creates a new GitHub API client with a custom base URL (for testing)

func (*Client) ExecuteBatchedTimelineQuery

func (c *Client) ExecuteBatchedTimelineQuery(query string) (*BatchedTimelineResponse, error)

ExecuteBatchedTimelineQuery executes a batched GraphQL query with aliases

func (*Client) ExecuteQuery

func (c *Client) ExecuteQuery(query string, variables map[string]interface{}) (*GraphQLResponse, error)

ExecuteQuery executes a GraphQL query

func (*Client) FetchAuthenticatedUserLogin

func (c *Client) FetchAuthenticatedUserLogin() (string, error)

FetchAuthenticatedUserLogin fetches the login of the authenticated user

type GraphQLError

type GraphQLError struct {
	Message string `json:"message"`
	Type    string `json:"type"`
}

GraphQLError represents a GraphQL error

type GraphQLResponse

type GraphQLResponse struct {
	Data struct {
		Search struct {
			Nodes    []PullRequestDTO `json:"nodes"`
			PageInfo struct {
				EndCursor   string `json:"endCursor"`
				HasNextPage bool   `json:"hasNextPage"`
			} `json:"pageInfo"`
		} `json:"search"`
	} `json:"data"`
	Errors []GraphQLError `json:"errors"`
}

GraphQLResponse represents the GitHub GraphQL API response

type LatestReviewsDTO

type LatestReviewsDTO struct {
	Nodes []ReviewDTO `json:"nodes"`
}

LatestReviewsDTO represents the latest reviews connection on a PR

type PullRequestDTO

type PullRequestDTO struct {
	Title      string    `json:"title"`
	URL        string    `json:"url"`
	Number     int       `json:"number"`
	CreatedAt  time.Time `json:"createdAt"`
	IsDraft    bool      `json:"isDraft"`
	Repository struct {
		NameWithOwner string `json:"nameWithOwner"`
	} `json:"repository"`
	Author struct {
		Login string `json:"login"`
	} `json:"author"`
	LatestReviews *LatestReviewsDTO `json:"latestReviews,omitempty"`
	Commits       *struct {
		Nodes []struct {
			Commit struct {
				StatusCheckRollup *struct {
					State string `json:"state"`
				} `json:"statusCheckRollup"`
			} `json:"commit"`
		} `json:"nodes"`
	} `json:"commits,omitempty"`
}

PullRequestDTO represents the GitHub API response for a pull request

type ReviewDTO

type ReviewDTO struct {
	Author struct {
		Login string `json:"login"`
	} `json:"author"`
	State       string    `json:"state"`
	SubmittedAt time.Time `json:"submittedAt"`
}

ReviewDTO represents a single review from the GitHub API

type TimelineItemDTO

type TimelineItemDTO struct {
	Typename  string    `json:"__typename"`
	CreatedAt time.Time `json:"createdAt"`
	Author    *struct {
		Login string `json:"login"`
	} `json:"author,omitempty"`
	Body   string `json:"body,omitempty"`
	State  string `json:"state,omitempty"` // For reviews
	Commit *struct {
		OID           string    `json:"oid"`
		CommittedDate time.Time `json:"committedDate"`
		Author        *struct {
			User *struct {
				Login string `json:"login"`
			} `json:"user"`
		} `json:"author"`
	} `json:"commit,omitempty"` // For commits
	Reactions *struct {
		Nodes []struct {
			Content   string    `json:"content"`
			CreatedAt time.Time `json:"createdAt"`
			User      *struct {
				Login string `json:"login"`
			} `json:"user"`
		} `json:"nodes"`
	} `json:"reactions,omitempty"` // For comment and review reactions
}

TimelineItemDTO represents a timeline item (comment, review, etc.)

Jump to

Keyboard shortcuts

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