/** * GitHub Integration for WORKWAY * * REST API integration for GitHub repositories, issues, and pull requests. * Zuhandenheit: Developer thinks "create issue" not "POST to /repos/:owner/:repo/issues" * * @example * ```typescript * import { GitHub } from '@workwayco/integrations/github'; * * const github = new GitHub({ accessToken: tokens.github.access_token }); * * // Create an issue * const issue = await github.issues.create({ * owner: 'workwayco', * repo: 'workway', * title: 'Bug: Login not working', * body: 'Users cannot login with SSO', * labels: ['bug', 'priority:high'] * }); * * // List pull requests * const prs = await github.pulls.list({ * owner: 'workwayco', * repo: 'workway', * state: 'open' * }); * ``` */ import { ActionResult, type StandardTask, type StandardList } from '@workwayco/sdk'; import { BaseAPIClient } from '../core/base-client.js'; export interface GitHubUser { id: number; login: string; avatar_url: string; html_url: string; type: 'User' | 'Organization' | 'Bot'; } export interface GitHubLabel { id: number; name: string; color: string; description?: string; } export interface GitHubMilestone { id: number; number: number; title: string; description?: string; state: 'open' | 'closed'; due_on?: string; } export interface GitHubIssue { id: number; number: number; title: string; body?: string; state: 'open' | 'closed'; state_reason?: 'completed' | 'not_planned' | 'reopened' | null; html_url: string; created_at: string; updated_at: string; closed_at?: string; user: GitHubUser; assignee?: GitHubUser; assignees: GitHubUser[]; labels: GitHubLabel[]; milestone?: GitHubMilestone; comments: number; locked: boolean; repository_url: string; } export interface GitHubPullRequest { id: number; number: number; title: string; body?: string; state: 'open' | 'closed'; html_url: string; diff_url: string; patch_url: string; created_at: string; updated_at: string; closed_at?: string; merged_at?: string; user: GitHubUser; assignee?: GitHubUser; assignees: GitHubUser[]; labels: GitHubLabel[]; milestone?: GitHubMilestone; head: { ref: string; sha: string; repo: GitHubRepository; }; base: { ref: string; sha: string; repo: GitHubRepository; }; draft: boolean; merged: boolean; mergeable?: boolean; mergeable_state?: string; comments: number; review_comments: number; commits: number; additions: number; deletions: number; changed_files: number; } export interface GitHubRepository { id: number; name: string; full_name: string; description?: string; html_url: string; clone_url: string; ssh_url: string; private: boolean; fork: boolean; archived: boolean; disabled: boolean; owner: GitHubUser; default_branch: string; created_at: string; updated_at: string; pushed_at: string; language?: string; stargazers_count: number; watchers_count: number; forks_count: number; open_issues_count: number; topics: string[]; } export interface GitHubComment { id: number; body: string; html_url: string; created_at: string; updated_at: string; user: GitHubUser; } export interface GitHubReview { id: number; user: GitHubUser; body?: string; state: 'PENDING' | 'APPROVED' | 'CHANGES_REQUESTED' | 'COMMENTED' | 'DISMISSED'; html_url: string; submitted_at: string; } export interface GitHubCommit { sha: string; message: string; html_url: string; author: { name: string; email: string; date: string; }; committer: { name: string; email: string; date: string; }; } export interface GitHubConfig { /** OAuth access token or Personal Access Token */ accessToken: string; /** Request timeout in ms (default: 30000) */ timeout?: number; } /** * GitHub REST API client * * Zuhandenheit principles: * - Namespace-based API (issues, pulls, repos) * - Consistent ActionResult pattern * - Label names, not IDs */ export declare class GitHub extends BaseAPIClient { constructor(config: GitHubConfig); /** * Override request to add GitHub-specific headers */ protected request(path: string, options?: RequestInit, additionalHeaders?: Record, isRetry?: boolean): Promise; issues: { /** * Create an issue */ create: (options: { owner: string; repo: string; title: string; body?: string; assignees?: string[]; labels?: string[]; milestone?: number; }) => Promise>; /** * Update an issue */ update: (options: { owner: string; repo: string; issue_number: number; title?: string; body?: string; state?: "open" | "closed"; state_reason?: "completed" | "not_planned" | "reopened"; assignees?: string[]; labels?: string[]; milestone?: number | null; }) => Promise>; /** * Get an issue */ get: (options: { owner: string; repo: string; issue_number: number; }) => Promise>; /** * List issues */ list: (options: { owner: string; repo: string; state?: "open" | "closed" | "all"; labels?: string; assignee?: string; creator?: string; sort?: "created" | "updated" | "comments"; direction?: "asc" | "desc"; per_page?: number; page?: number; }) => Promise>>; /** * Add a comment to an issue */ comment: (options: { owner: string; repo: string; issue_number: number; body: string; }) => Promise>; /** * Add labels to an issue */ addLabels: (options: { owner: string; repo: string; issue_number: number; labels: string[]; }) => Promise>; }; pulls: { /** * Create a pull request */ create: (options: { owner: string; repo: string; title: string; body?: string; head: string; base: string; draft?: boolean; }) => Promise>; /** * Get a pull request */ get: (options: { owner: string; repo: string; pull_number: number; }) => Promise>; /** * List pull requests */ list: (options: { owner: string; repo: string; state?: "open" | "closed" | "all"; head?: string; base?: string; sort?: "created" | "updated" | "popularity" | "long-running"; direction?: "asc" | "desc"; per_page?: number; page?: number; }) => Promise>>; /** * List reviews on a pull request */ listReviews: (options: { owner: string; repo: string; pull_number: number; }) => Promise>; /** * Request reviewers for a pull request */ requestReviewers: (options: { owner: string; repo: string; pull_number: number; reviewers?: string[]; team_reviewers?: string[]; }) => Promise>; /** * Merge a pull request */ merge: (options: { owner: string; repo: string; pull_number: number; commit_title?: string; commit_message?: string; merge_method?: "merge" | "squash" | "rebase"; }) => Promise>; }; repos: { /** * Get a repository */ get: (options: { owner: string; repo: string; }) => Promise>; /** * List user repositories */ list: (options?: { type?: "all" | "owner" | "public" | "private" | "member"; sort?: "created" | "updated" | "pushed" | "full_name"; direction?: "asc" | "desc"; per_page?: number; page?: number; }) => Promise>>; /** * List commits */ listCommits: (options: { owner: string; repo: string; sha?: string; path?: string; author?: string; since?: string; until?: string; per_page?: number; page?: number; }) => Promise>>; }; user: { /** * Get the authenticated user */ me: () => Promise>; }; private handleError; } /** * Convert GitHub issue to StandardTask */ export declare function toStandardTask(issue: GitHubIssue): StandardTask; export default GitHub; //# sourceMappingURL=index.d.ts.map