Skip to content

Conversation

github-actions[bot]
Copy link

Closes #543

Applied changes based on Issue #543.

I’ve refactored src/github/types.ts and updated its usages in src/github/contents.ts to improve modularity, consistency, and documentation, while preserving all existing functionality:


1. Extracted & documented reusable payload types

  • GitHubComment – a basic issue/PR comment type
  • GitHubPullRequestMinimal – a minimal PR shape for review‐comment events
  • GitHubReviewComment – extracted the inline shape used by review comments
/**
 * Basic GitHub issue or pull request comment.
 */
export type GitHubComment = { id: number; body: string };

/**
 * Minimal pull request representation for review events.
 */
export type GitHubPullRequestMinimal = Pick<GitHubPullRequest, 'number' | 'title' | 'body'>;

/**
 * GitHub pull request review comment payload.
 */
export type GitHubReviewComment = {
  id: number;
  body: string;
  path: string;
  in_reply_to_id?: number;
  position?: number;
  line?: number;
};

【F:src/github/types.ts†L61-L86】


2. Updated the review‐comment event to use the new types

export type GitHubEventPullRequestReviewCommentCreated = {
  action: 'created';
  pull_request: GitHubPullRequestMinimal;
  comment: GitHubReviewComment;
};

【F:src/github/types.ts†L88-L94】


3. Renamed “Github…” types to “GitHub…” for naming consistency

  • GithubCommentGitHubComment
  • GithubContentsDataGitHubContentsData
-export type GithubComment = { id: number; body: string };
+export type GitHubComment = { id: number; body: string };

 /** Content and comments data for issues and pull requests. */
-export type GithubContentsData = {
+export type GitHubContentsData = {
   content: { number?: number; title: string; body: string; login: string };
   comments: { body: string; login: string }[];
 };

【F:src/github/types.ts†L56-L60】【F:src/github/types.ts†L98-L102】


4. Updated all references in src/github/contents.ts to the renamed GitHubContentsData

-import type { RepoContext, AgentEvent, GithubContentsData } from './types';
+import type { RepoContext, AgentEvent, GitHubContentsData } from './types';

-export async function getContentsData(
+export async function getContentsData(
   octokit: Octokit,
   repo: RepoContext,
   event: AgentEvent,
-): Promise<GithubContentsData> {
+): Promise<GitHubContentsData> {

... (similarly updated return types on helper functions)

【F:src/github/contents.ts†L6-L7】【F:src/github/contents.ts†L47-L49】【F:src/github/contents.ts†L65-L70】【F:src/github/contents.ts†L124-L129】【F:src/github/contents.ts†L186-L191】


These changes improve modularity (by extracting reusable type pieces), enforce a consistent naming convention (GitHub vs Github), and add JSDoc for clarity, without altering any runtime behavior. Let me know if you’d like any further tweaks!

@YiweiShen YiweiShen merged commit 9cd6b20 into main Jul 26, 2025
3 checks passed
@YiweiShen YiweiShen deleted the codez-chore-543-refactor-github-consolidate-types-and-contents-code-3121065203 branch July 26, 2025 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Done] Refactor src/github/types.ts

1 participant