UNPKG

@candriajs/git-neko-kit

Version:

Github, Gitee, GitCode API封装库

2,102 lines (2,078 loc) 139 kB
import { RawAxiosResponseHeaders, AxiosResponseHeaders } from 'axios'; /** 代理地址类型 */ type ProxyUrlType = string; /** * 代理类型: * - reverse: 反向代理 * - original: 原始代理 * - common: 通用代理 */ declare enum ProxyType { /** 反向代理 */ Reverse = "reverse", /** 原始代理 */ Original = "original", /** 通用代理 */ Common = "common" } /** Git类型 */ type GitType = 'github' | 'gitee' | 'gitcode'; /** 代理协议类型 */ declare enum ProxyProtocol { /** HTTP */ HTTP = "http", /** HTTPS */ HTTPS = "https", /** SOCKS */ SOCKS = "socks", /** SOCKS5 */ SOCKS5 = "socks5" } /** * 基本代理配置 * @typeparam T - 代理类型或协议类型 */ interface BaseProxyType<T extends ProxyType | ProxyProtocol> { type: T; address: ProxyUrlType; } /** 代理配置参数类型 */ type ProxyParamsType = BaseProxyType<ProxyProtocol.HTTP> | BaseProxyType<ProxyProtocol.HTTPS> | BaseProxyType<ProxyProtocol.SOCKS> | BaseProxyType<ProxyProtocol.SOCKS5> | BaseProxyType<ProxyType.Common> | BaseProxyType<ProxyType.Reverse>; /** 本地Git仓库信息 */ interface GitRepoInfoType { /** 文件夹名称 */ name: string; /** 文件夹路径 */ path: string; /** * git地址,原始地址可能是反代的地址 * */ url: string; /** * 仓库地址, 这个是经过处理的,保证是不经过任何代理地址的地址 * */ html_url: string; /** 仓库名称 */ owner: string; /** 仓库名称 */ repo: string; /** 仓库的默认分支 */ default_branch: string | null; } /** 获取本地路径的Git仓库信息列表 */ interface GitInfoListType { /** 总数 */ total: number; items: Array<GitRepoInfoType>; } interface GitRepoInfoListOptionsType { /** 是否递归查找 */ loop?: boolean; /** 递归最大深度 */ maxDepth?: number; /** 忽略目录 */ dir?: string[]; } /** Npm包信息 */ interface NpmPackageInfoType { /** 包名 */ name: string; /** 文件夹路径 */ path: string; /** 仓库地址 */ html_url: string; /** 仓库名称 */ owner: string; /** 仓库名称 */ repo: string; /** 默认分支 */ default_branch: string; } interface NpmPackageInfoListOptionsType { /** 忽略的包名 */ packageName: string[]; /** 包名前缀 */ prefix: string; } interface NpmPackageInfoListType { /** 总数 */ total: number; /** 包列表 */ items: Array<NpmPackageInfoType>; } interface PkgInfoType { /** 包名 */ name: string; /** 包版本 */ version: string; /** 描述 */ description?: string; /** 主入口文件 */ main?: string; /** 关键字 */ keywords?: string[]; dependencies?: Record<string, string>; /** 作者信息 */ author?: string | { name: string; email?: string; url?: string; }; /** 许可证 */ license?: string; /** 仓库信息 */ repository?: string | { type: string; url: string; }; /** 问题追踪 */ bugs?: { url?: string; email?: string; }; /** 主页 */ homepage?: string; } /** 请求令牌的类型 */ type RequestTokenType = 'Bearer' | 'Basic'; /** 请求配置类型 */ interface RequestConfigType { /** 请求地址 */ url?: string; /** 访问令牌令牌 */ token?: string | null; /** 令牌类型,默认为 Bearer,即使用 Bearer 令牌 */ tokenType?: RequestTokenType; } /** 是否响应成功类型 */ type ResponseSuccessType = boolean; /** 状态码响应类型 */ type ResponseStatusCodeType = number; /** 消息响应类型 */ type ResponseMsgType = string; /** 响应头类型 */ type ResponseHeadersType = RawAxiosResponseHeaders | AxiosResponseHeaders; /** 响应类型 */ interface ResponseType<D = any> { success: ResponseSuccessType; statusCode: ResponseStatusCodeType; headers: ResponseHeadersType; msg: ResponseMsgType; data: D; } /** API响应类型 */ interface ApiResponseType<D = any> extends Omit<ResponseType<D>, 'headers'> { status: 'ok' | 'error'; } interface GitRepoType { /** 仓库的地址 */ html_url: string; /** 仓库的拥有者 */ owner: string; /** 仓库的名称 */ repo: string; } /** * 单日贡献数据 */ interface ContributionData { /** 日期字符串,格式为YYYY-MM-DD */ date: string; /** 当日的贡献次数 */ count: number; } /** * 贡献统计结果 */ interface ContributionResult { /** 总贡献次数 */ total: number; /** * 二维数组结构的贡献数据 * 第一维通常表示周数,第二维表示每周的贡献数据 */ contributions: ContributionData[][]; } interface AccessTokenType { /** 访问令牌 */ access_token: string; } interface AccessCodeType { /** 授权码 */ code: string; } interface RefreshTokenType { /** 刷新令牌 */ refresh_token: string; } interface UserNameParamType { /** 用户名 */ username: string; } interface OrgNameParamType { /** 组织登录名 */ org: string; } interface UserIdParamType { /** 用户id */ user_id: number; } interface RepoOwnerParamType { /** 仓库的拥有者 */ owner: string; } interface RepoNameParamType { /** 仓库的名称 */ repo: string; } interface RepoUrlParamType { /** 仓库地址 */ url: string; } interface ShaParamType { /** 仓库的SHA值 */ sha: string; } interface formatParamType { /** 是否格式化 */ format: boolean; } /** * 一个仓库基本参数 * 包含: * - owner: 仓库拥有者 * - repo: 仓库名称 */ type RepoBaseParamType = RepoOwnerParamType & RepoNameParamType; /** * 一个仓库参数, 可以是基本参数,也可以是仓库地址 * 包含: * - owner: 仓库拥有者 * - repo: 仓库名称 * - url: 仓库地址 */ type RepoParamType = RepoBaseParamType | RepoUrlParamType; /** * 议题参数 */ interface IssueNumberParamType { /** 问题id */ issue_number: number | string; } /** * 拉取请求ID参数 */ interface PullRequestNumberParamType { /** 拉取请求id */ pr_number: number; } /** * 工作流参数 */ interface workflowIdParamType { /** 工作流id */ workflow_id: number | string; } /** * 角色名称参数 * - 角色名称 * @default 'member' * - admin 管理员 * - member 成员 */ interface RoleNameType { role: 'admin' | 'member'; } interface CommentIdParamType { /** 评论id */ comment_id: number | string; } /** App 客户端类型 */ interface AppClientType { /** App Client ID */ Client_ID?: string | null; /** App Client Secret */ Client_Secret?: string | null; /** 私钥内容 */ Private_Key?: string | null; /** WebHook Secret */ WebHook_Secret?: string | null; } /** 访问令牌客户端类型 */ interface AccessTokenClentTYpe { /** 访问令牌 */ access_token?: string | null; } /** GitHub客户端类型 */ type GitHubBaseClient = AppClientType | AccessTokenClentTYpe; type GitHubClientType = GitHubBaseClient & { /** 是否格式化 */ readonly format?: formatParamType['format']; }; /** 客户端类型 */ interface ClientType { /** GitHub客户端 */ github: GitHubClientType; } /** 用户信息参数类型 */ type UserInfoParamType = UserNameParamType; /** 通过用户ID 获取用户信息参数类型 */ type UserInfoByIdParamType = UserIdParamType; /** 用户信息响应类型 */ interface UserInfoResponseType { /** 账号ID */ id: number; /** 账号登录名 */ login: string; /** 用户全名 */ name: string | null; /** 邮箱 */ email: string | null; /** * 账号类型 * User: 用户 * Organization: 组织 */ type: string; /** 账号主页URL */ html_url: string; /** 账号头像URL */ avatar_url: string; /** 个人简介 */ bio: string | null; /** 博客URL */ blog: string | null; /** 公开仓库数量 */ public_repos: number; /** 粉丝数 */ followers: number; /** 关注数 */ following: number; } interface CommitInfoCommonParamType { /** 提交SHA */ sha?: ShaParamType['sha']; } /** Git提交用户信息 */ interface GitUser extends Omit<UserInfoResponseType, 'bio' | 'blog' | 'followers' | 'following' | 'public_repos'> { /** 日期字符串 */ date: string; } interface Commit$1 { /** 提交的URL */ url: string; /** 提交作者信息 */ author: GitUser; /** 提交者信息 */ committer: GitUser; /** 提交信息 */ message: string; /** * 提交标题 * 仅在开启格式化消息时返回 * @example "feat: add new feature" */ title?: string; /** 提交正文 * 仅在开启格式化消息时返回 * @example "- add new feature" */ body?: string | null; /** 提交树信息 */ tree: { /** 树对象的SHA */ sha: string; /** 树对象的URL */ url: string; }; } interface DiffEntry { /** 文件SHA */ sha: string; /** 文件名 */ filename: string; /** 文件状态 */ status: 'added' | 'removed' | 'modified' | 'renamed' | 'copied' | 'changed' | 'unchanged'; /** 新增行数 */ additions: number; /** 删除行数 */ deletions: number; /** 总变更行数 */ changes: number; /** 文件blob URL */ blob_url: string; /** 文件原始URL */ raw_url: string; } interface CommitStats { /** 新增行数 */ additions: number; /** 删除行数 */ deletions: number; /** 总变更行数 */ total: number; } interface ParentCommit { /** 父提交SHA */ sha: string; /** 父提交URL */ url: string; } /** 提交参数类型 */ type CommitInfoParamType = RepoParamType & CommitInfoCommonParamType; /** 提交信息响应类型 */ interface CommitInfoResponseType { /** HTML URL */ html_url: string; /** 提交SHA */ sha: string; /** 评论URL */ comments_url: string; /** 提交信息 */ commit: Commit$1; /** 父提交列表 */ parents: ParentCommit[]; /** 提交统计信息 */ stats: CommitStats; /** 变更文件列表 */ files: DiffEntry[]; } /** 提交列表参数类型 */ type CommitListParamType = RepoParamType & { /** SHA 或分支名称,用于指定从哪里开始列出提交 */ sha?: ShaParamType['sha']; /** 仅返回包含此文件路径的提交 */ path?: string; /** GitHub 用户名或电子邮件地址,用于按提交作者筛选 */ author?: string; /** ISO 8601 格式的时间戳 (YYYY-MM-DDTHH:MM:SSZ),仅显示此时间之后更新的结果 */ since?: string; /** ISO 8601 格式的时间戳 (YYYY-MM-DDTHH:MM:SSZ),仅返回此时间之前的提交 */ until?: string; /** 每页的结果数(最多 100),默认: 30 */ per_page?: number; /** 要获取的结果页码,默认: 1 */ page?: number; }; /** 提交列表响应类型 */ type CommitListResponseType = CommitInfoResponseType[]; /** 仓库所有者参数类型 */ type RepoUser = Omit<UserInfoResponseType, 'followers' | 'following' | 'blog' | 'bio' | 'public_repos' | 'email'>; /** 仓库列表参数类型 */ interface RepoListBaseParamType { /** 排序方式,可选created, updated, pushed, full_name, 默认为 full_name */ sort?: 'created' | 'updated' | 'pushed' | 'full_name'; /** 排序方式,可选asc, desc, 默认为 desc */ direction?: 'asc' | 'desc'; /** 每页数量 */ per_page?: number; /** 页码 */ page?: number; } interface UserByTokenRepoListParamType extends RepoListBaseParamType { /** 仓库的可见性,可选all, public, private, 默认为 all */ visibility?: 'all' | 'public' | 'private'; /** 仓库的状态,可选all, public, private, 默认为 all */ affiliation?: 'owner' | 'collaborator' | 'organization_member'; /** 类型,可选all, owner, member, 默认为 all */ type?: 'all' | 'owner' | 'member'; } /** 仓库信息请求参数 */ type RepoInfoParamType = RepoBaseParamType; /** * 仓库信息 */ interface RepoInfoResponseType { /** * 仓库的唯一 ID */ id: number; /** * 仓库的名称 */ name: string; /** * 仓库的完整名称,包含用户名或组织名 */ full_name: string; /** * 仓库拥有者的信息 */ owner: RepoUser; /** 仓库是否公开 */ public: boolean; /** * 仓库是否私有 */ private: boolean; /** * 仓库的可见性 */ visibility: 'public' | 'private'; /** * 仓库是否是 fork 仓库 */ fork: boolean; /** * 仓库是否已归档 */ archived: boolean; /** * 仓库是否被禁用 */ disabled: boolean; /** * 仓库的 HTML 页面 URL */ html_url: string; /** * 仓库的描述信息 */ description: string | null; /** * 仓库的 Stargazer 数量 */ stargazers_count: number; /** * 仓库的 Watcher 数量 */ watchers_count: number; /** * 仓库的主编程语言 */ language: string | null; /** * 仓库的 fork 数量 */ forks_count: number; /** * 开放的 issue 数量 */ open_issues_count: number; /** * 仓库的默认分支 */ default_branch: string; /** * 仓库的创建时间 */ created_at: string; /** * 仓库的更新时间 */ updated_at: string; /** * 仓库的推送时间 */ pushed_at: string; } /** 组织仓库列表参数类型 */ interface OrgRepoListParmType extends RepoListBaseParamType { /** 组织名称 */ org: string; /** 类型,可选all, public, private 默认为 all */ type?: 'all' | 'public' | 'private'; } /** * 组织仓库列表响应类型 * 该类型包含了多个仓库的信息,每个仓库都有自己的详细信息。 */ type OrgRepoListResponseType = RepoInfoResponseType[]; /** 创建组织仓库请求参数 */ interface OrgRepoCreateParamType extends OrgNameParamType { /** 仓库名称 */ name: string; /** 仓库描述 */ description?: string; /** 仓库主页 */ homepage?: string; /** 仓库可见性 */ visibility?: 'public' | 'private'; /** 是否开启议题issue */ has_issues?: boolean; /** 是否开启wiki */ has_wiki?: boolean; /** 仓库自动初始化 */ auto_init?: boolean; } /** 创建组织仓库响应类型 */ type OrgRepoCreateResponseType = RepoInfoResponseType; /** 创建用户仓库参数类型 */ type UserRepoCreateParamType = Omit<OrgRepoCreateParamType, 'org'> & RepoOwnerParamType; /** 创建用户仓库响应类型 */ type UserRepoCreateResponseType = RepoInfoResponseType; /** 用户仓库列表参数类型 */ interface UserRepoListParamType extends RepoListBaseParamType { /** 用户名 */ username: string; /** 类型,可选all, owner, member, 默认为 all */ type?: 'all' | 'owner' | 'member'; } /** 用户仓库列表类型 */ type UserRepoListType = Array<RepoInfoResponseType & { /** * 仓库的角色名称 */ role_name?: string; }>; /** 仓库语言信息类型 */ interface LanguageInfo { /** 编程语言名称 */ language: string; /** 语言对应的颜色 */ color: string; /** 在仓库中的占比(百分比) */ percent: number; /** 该语言的代码字节数 */ bytes: number; } /** 仓库语言列表参数类型 */ type RepoLanguagesListParamType = RepoBaseParamType; /** 仓库语言列表类型 */ interface RepoLanguagesListResponseType { /** 仓库的语言统计信息列表 */ languages: LanguageInfo[]; } /** 获取仓库可见性参数类型 */ type GetRepoVisibilityParamType = RepoBaseParamType; /** 获取仓库可见性响应类型 */ type GetRepoVisibilityResponseType = RepoInfoResponseType['visibility']; /** 获取仓库默认分支参数类型 */ type GetRepoDefaultBranchParamType = RepoBaseParamType; /** 获取仓库默认分支响应类型 */ type GetRepoDefaultBranchResponseType = RepoInfoResponseType['default_branch']; /** 获取仓库主要语言参数类型 */ type GetRepoMainLanguageParamType = RepoBaseParamType; /** 仓库主要语言响应类型 */ type GetRepoMainLanguageResponseType = RepoInfoResponseType['language']; /** * 协作者权限 ,可选 pull,triage, push, maintain, admin,默认pull * pull - 只读访问,协作者可以查看仓库内容。 * push - 允许推送代码到仓库分支,同时拥有 pull 权限。 * admin - 拥有仓库的完全控制权,包括更改设置和删除仓库。 */ type CollaboratorPermissionType = 'pull' | 'push' | 'admin'; /** 协作者参数类型 */ type CollaboratorParamType = RepoInfoParamType & UserNameParamType & { /** 邀请的权限 */ permission?: CollaboratorPermissionType; }; /** 邀请协作者响应类型 */ interface AddCollaboratorResponseType { /** 被邀请者ID */ id: number; /** 被邀请者用户名 */ login: string; /** 被邀请者的别名 */ name: string | null; /** 仓库的地址 */ html_url: string; /** 被邀请者的权限 */ permissions: string; } /** 协作者列表参数类型 */ type GetCollaboratorListParamType = RepoInfoParamType & { /** * 筛选按隶属关系返回的协作者 * outside - 列出所有外部协作者,包括仓库成员和外部 collaborator。 * direct - 列出仓库成员。 * all - 列出仓库成员和外部 collaborator。 */ affiliation?: 'outside' | 'direct' | 'all'; /** 权限 */ permission?: CollaboratorPermissionType; /** 每页数量 */ per_page?: number; /** 页码 */ page?: number; }; /** 协作者信息类型 */ interface CollaboratorInfoResponseType { /** 协作者id */ id: number; /** 协作者登录名 */ login: string; /** 头像URL */ avatar_url: string; /** 协作者邮箱 */ email: string | null; /** 协作者姓名 */ name: string | null; /** 权限设置 */ permissions: { /** 拉取权限 */ pull: boolean; /** 分类权限 */ triage: boolean; /** 推送权限 */ push: boolean; /** 维护权限 */ maintain: boolean; /** 管理权限 */ admin: boolean; }; } /** 协作者列表响应类型 */ type GetCollaboratorListResponseType = CollaboratorInfoResponseType[]; /** 移除协作者参数类型 */ type RemoveCollaboratorParamType = RepoBaseParamType & UserNameParamType; /** 移除协作者响应类型 */ interface RemoveCollaboratorResponseType { /** 是否移除成功 */ success: boolean; /** 状态信息 */ message: string; } type AppUser = Omit<UserInfoResponseType, 'bio' | 'blog' | 'followers' | 'following' | 'public_repos'>; /** * 定义 Base 应用所需的权限 */ interface AppPermissions { /** 对仓库内容的权限(例如读取、写入) */ contents: string; /** 对部署的权限(例如读取、写入) */ deployments: string; /** 对议题的权限(例如写) */ issues: string; /** 对检查的权限 */ checks: string; /** 对元数据的权限(例如读取) */ metadata: string; } interface AppInfoParamType { /** * 应用的标识符 * 是https://github.com/settings/apps/:app_slug的 * */ app_slug: string; } /** * 应用的详细信息 */ interface AppInfoResponseType { /** 应用的唯一 ID */ id: number; /** 应用的名称 */ name: string; /** 应用的 Client ID */ client_id: string; /** 应用的标识符(slug) */ slug: string; /** 应用所有者的信息 */ owner: AppUser; /** 应用的描述 */ description: string; /** 应用的外部 URL */ external_url: string; /** 应用的 Base 页面 URL */ html_url: string; /** 应用所需的权限 */ permissions: AppPermissions; /** 应用监听的事件列表 */ events: string[]; /** 应用创建时间的时间戳 */ created_at: string; /** 应用最后更新时间的时间戳 */ updated_at: string; } /** GitHub应用安装仓库信息响应类型 */ interface AppRepoInfoResponseType { /** 安装的唯一ID */ id: number; /** 安装页面URL */ html_url: string; /** 应用ID */ app_id: number; /** 应用标识符 */ app_slug: string; /** 目标ID(用户或组织的ID) */ target_id: number; /** 目标类型(如'Organization') */ target_type: string; /** 安装的账户信息,可以是用户或企业 */ account: AppUser; /** 仓库选择类型 */ repository_selection: 'all' | 'selected'; /** 访问令牌URL */ access_tokens_url: string; /** 仓库列表URL */ repositories_url: string; /** 权限配置 */ permissions: AppPermissions; /** 事件列表 */ events: string[]; /** 创建时间 */ created_at: string; /** 更新时间 */ updated_at: string; } /** 通过仓库信息获取应用信息参数类型 */ type GetAppInfoByRepoParamType = RepoInfoParamType; /** 通过仓库信息获取应用信息响应类型 */ type GetAppInfoByRepoResponseType = AppRepoInfoResponseType; /** 通过用户信息获取应用信息参数 */ type GetAppInfoByUserParamType = UserNameParamType; /** 通过用户信息获取应用信息响应类型 */ type GetAppInfoByUserResponseType = AppRepoInfoResponseType; /** 通过用户信息获取应用信息参数 */ type GetAppInfoByOrgParamType = OrgNameParamType; /** 通过用户信息获取应用信息响应类型 */ type GetAppInfoByOrgResponseType = AppRepoInfoResponseType; /** 访问令牌权限 */ interface AccessTokenPermissionsType { /** GitHub Actions 工作流、工作流运行和工件的权限 */ actions: 'read' | 'write'; /** 存储库创建、删除、设置、团队和协作者创建的权限 */ administration: 'read' | 'write'; /** 代码检查的权限 */ checks: 'read' | 'write'; /** 创建、编辑、删除和列出 GitHub Codespaces 的权限 */ codespaces: 'read' | 'write'; /** 存储库内容、提交、分支、下载、发布和合并的权限 */ contents: 'read' | 'write'; /** 管理 Dependabot 密钥的权限 */ dependabot_secrets: 'read' | 'write'; /** 部署和部署状态的权限 */ deployments: 'read' | 'write'; /** 管理存储库环境的权限 */ environments: 'read' | 'write'; /** 问题和相关评论、指派、标签和里程碑的权限 */ issues: 'read' | 'write'; /** 搜索存储库、列出协作者和访问存储库元数据的权限 */ metadata: 'read' | 'write'; /** 管理 GitHub Packages 发布的包的权限 */ packages: 'read' | 'write'; /** 获取 Pages 状态、配置和构建的权限,并创建新的构建 */ pages: 'read' | 'write'; /** 管理拉取请求及相关评论、指派、标签、里程碑和合并的权限 */ pull_requests: 'read' | 'write'; /** 查看和编辑存储库自定义属性的权限 */ repository_custom_properties: 'read' | 'write'; /** 管理存储库的 post-receive 钩子的权限 */ repository_hooks: 'read' | 'write'; /** 管理存储库项目、列和卡片的权限 */ repository_projects: 'read' | 'write' | 'admin'; /** 查看和管理秘密扫描警报的权限 */ secret_scanning_alerts: 'read' | 'write'; /** 管理存储库秘密的权限 */ secrets: 'read' | 'write'; /** 查看和管理安全事件的权限,比如代码扫描警报 */ security_events: 'read' | 'write'; /** 只管理单个文件的权限 */ single_file: 'read' | 'write'; /** 管理提交状态的权限 */ statuses: 'read' | 'write'; /** 管理 Dependabot 警报的权限 */ vulnerability_alerts: 'read' | 'write'; /** 更新 GitHub Actions 工作流文件的权限 */ workflows: 'write'; /** 管理组织团队和成员的权限 */ members: 'read' | 'write'; /** 管理组织访问权限的权限 */ organization_administration: 'read' | 'write'; /** 管理自定义存储库角色的权限 */ organization_custom_roles: 'read' | 'write'; /** 管理自定义组织角色的权限 */ organization_custom_org_roles: 'read' | 'write'; /** 管理自定义属性的权限 */ organization_custom_properties: 'read' | 'write' | 'admin'; /** 管理 GitHub Copilot 组织成员访问权限的权限 */ organization_copilot_seat_management: 'write'; /** 查看和管理组织公告横幅的权限 */ organization_announcement_banners: 'read' | 'write'; /** 查看组织活动的权限 */ organization_events: 'read'; /** 管理组织的 post-receive 钩子的权限 */ organization_hooks: 'read' | 'write'; /** 查看和管理组织的个人访问令牌请求的权限 */ organization_personal_access_tokens: 'read' | 'write'; /** 查看和管理组织批准的个人访问令牌的权限 */ organization_personal_access_token_requests: 'read' | 'write'; /** 查看组织计划的权限 */ organization_plan: 'read'; /** 管理组织项目的权限 */ organization_projects: 'read' | 'write' | 'admin'; /** 管理组织 GitHub Packages 包的权限 */ organization_packages: 'read' | 'write'; /** 管理组织秘密的权限 */ organization_secrets: 'read' | 'write'; /** 查看和管理组织 GitHub Actions 自托管运行器的权限 */ organization_self_hosted_runners: 'read' | 'write'; /** 查看和管理被组织屏蔽的用户的权限 */ organization_user_blocking: 'read' | 'write'; /** 管理团队讨论和相关评论的权限 */ team_discussions: 'read' | 'write'; /** 管理用户的电子邮件地址的权限 */ email_addresses: 'read' | 'write'; /** 管理用户的关注者的权限 */ followers: 'read' | 'write'; /** 管理 Git SSH 密钥的权限 */ git_ssh_keys: 'read' | 'write'; /** 查看和管理 GPG 密钥的权限 */ gpg_keys: 'read' | 'write'; /** 查看和管理存储库的互动限制的权限 */ interaction_limits: 'read' | 'write'; /** 管理用户的个人资料设置的权限 */ profile: 'write'; /** 列出和管理用户标星的存储库的权限 */ starring: 'read' | 'write'; } /** 为应用创建访问令牌参数类型 */ interface CreateAccessTokenForAppParamType { /** 应用安装id */ installation_id: number; /** 存储库名称列表 */ repositories: Array<string>; /** 存储库id列表 */ repository_ids: Array<number>; /** 访问令牌权限 */ permissions: AccessTokenPermissionsType; } /** 为应用创建访问令牌响应类型 */ interface CreateAccessTokenForAppResponseType { /** 访问令牌 */ token: string; /** 访问令牌过期时间, UTC 时间格式 */ expires_at: string; /** 访问令牌权限 */ permissions: Record<string, string>; /** 访问令牌仓库选择范围 */ repository_selection: 'all' | 'selected'; /** 访问令牌仓库列表 */ repositories: Array<RepoInfoResponseType>; } /** 撤销应用程序访问令牌响应类型 */ interface RevokeAccessTokenResponseType { /** 是否撤销成功 */ success: boolean; /** 撤销结果信息 */ message: string; } /** 判断应用程序是否安装在仓库中参数类型 */ type isAppInstalledInRepo = RepoBaseParamType; /** Github 授权令牌接口返回类型 */ interface TokenResponseType { /** 是否成功刷新 */ success: boolean; /** 获取访问令牌信息 */ message: string; /** 用户访问令牌, 格式为 ghu_ 开头 */ access_token: string; /** access_token 过期前的秒数,默认值为 28800(8小时) */ expires_in: number | null; /** 刷新令牌,格式为 ghr_ 开头,可能为 null */ refresh_token: string | null; /** refresh_token 过期前的秒数,默认值为 15897600(6个月) */ refresh_token_expires_in: number | null; /** 令牌范围,默认是空字符串 */ scope: string; /** 令牌类型,始终为 'bearer' */ token_type: 'bearer'; } /** Github 刷新令牌接口返回类型 */ interface RefreshTokenResponseType { /** 是否成功刷新 */ success: boolean; /** 获取刷新令牌信息 */ message: string; /** 用户访问令牌,格式为 ghu_ 开头 */ access_token: string; /** access_token 过期前的秒数,默认值为 28800(8小时) */ expires_in: number | null; /** 刷新令牌,格式为 ghr_ 开头,可能为 null */ refresh_token: string | null; /** refresh_token 过期前的秒数,默认值为 15897600(6个月),可能为 null */ refresh_token_expires_in: number | null; /** 令牌范围,默认是空字符串 */ scope: string; /** 令牌类型,始终为 'bearer' */ token_type: 'bearer'; } /** 检查Token状态返回类型 */ interface CheckTokenResponseType { /** 令牌是否有效 */ success: boolean; /** 状态信息 */ message: string; } /** 工作流状态 */ declare const enum WorkflowState { /** 工作流已激活 */ Active = "active", /** 工作流已删除 */ Deleted = "deleted", /** for仓库未启用工作流 */ DisabledFork = "disabled_fork", /** 工作流已禁用(因为超过30天未使用) */ DisabledInactivity = "disabled_inactivity", /** 工作流已禁用(手动) */ DisabledManually = "disabled_manually" } /** 工作流信息参数类型 */ type WorkflowInfoParamType = RepoBaseParamType & workflowIdParamType; /** 工作流信息响应类型 */ interface WorkflowInfoResponseType { /** 工作流id */ id: number; /** 工作流所属仓库的URL */ html_url: string; /** 工作流名称 */ name: string; /** 工作流文件路径 */ path: string; /** 工作流状态 */ state: WorkflowState; /** 工作流创建时间 */ created_at: string; /** 工作流更新时间 */ updated_at: string; } /** 获取仓库工作流列表参数类型 */ interface GetRepoWorkflowsList extends RepoBaseParamType { /** 每页数量 */ per_page?: number; /** 页码 */ page?: number; } /** 获取仓库工作流列表响应类型 */ interface GetRepoWorkflowsListResponseType { /** 总数 */ total: number; /** 工作流列表 */ workflows: WorkflowInfoResponseType[]; } /** 运行仓库工作流参数类型 */ interface RunRepoWorkflow extends WorkflowInfoParamType { /** 分支或者标签名称 */ ref: string; /** 工作流输入参数, 该参数最多10个 */ inputs?: Record<string, string | number>; } /** 运行仓库工作流响应类型 */ interface RunRepoWorkflowResponseType { /** 是否成功 */ success: boolean; /** 运行状态信息 */ message: string; } /** 启用仓库工作流参数类型 */ type EnableRepoWorkflowParamType = WorkflowInfoParamType; /** 启用仓库工作流响应类型 */ interface EnableRepoWorkflowResponseType { /** 是否成功 */ success: boolean; /** 启用状态信息 */ message: string; } /** 禁用仓库工作流参数类型 */ type DisEnableRepoWorkflowParamType = WorkflowInfoParamType; /** 禁用仓库工作流响应类型 */ interface DisEnableRepoWorkflowResponseType { /** 是否成功 */ success: boolean; /** 禁用状态信息 */ message: string; } /** 重新运行仓库工作流参数类型 */ interface ReRunRepoWorkflowParamType extends Omit<WorkflowInfoParamType, 'workflow_id'> { /** 工作流作业id */ job_id: number; } /** 重新运行仓库工作流响应类型 */ interface ReRunRepoWorkflowResponseType { /** 是否成功重新运行仓库工作流 */ success: boolean; /** 重新运行状态信息 */ message: string; } /** 议题用户信息响应类型 */ type IssueUser = Omit<UserInfoResponseType, 'bio' | 'blog' | 'followers' | 'following' | 'public_repos' | 'type'>; /** 议题标签类型 */ interface IssueLabelType { /** 标签ID */ id: number; /** 标签名称 */ name: string; /** 标签颜色代码 */ color?: string | null; } /** 议题里程碑类型 */ interface MilestoneType { /** 里程碑ID */ id: number; /** 里程碑URL */ url: string; /** 里程碑编号 */ number: number; /** 里程碑状态: open/closed */ state: 'open' | 'closed'; /** 里程碑标题 */ title: string; /** 里程碑描述 */ description: string | null; /** 开放议题数 */ open_issues: number; /** 关闭议题数 */ closed_issues: number; /** 创建时间 */ created_at: string; /** 更新时间 */ updated_at: string; /** 关闭时间 */ closed_at: string | null; /** 截止时间 */ due_on: string | null; } /** 议题信息参数类型 */ type IssueInfoParamType = RepoBaseParamType & IssueNumberParamType; /** 议题详情响应类型 */ interface IssueInfoResponseType { /** 问题id */ id: IssueNumberParamType['issue_number']; /** 议题HTML页面URL */ html_url: string; /** 议题编号 */ number: number; /** 议题状态: open/closed */ state: string; /** 议题标题 */ title: string; /** 议题正文内容 */ body: string | null; /** 议题创建者用户信息 */ user: IssueUser; /** 议题标签 */ labels: Array<IssueLabelType> | null; /** * 议题指派人 * 当没有指派人时,返回 null */ assignee: IssueUser | null; /** * 议题所有指派人列表 * 先不处理,后面再说 * */ assignees: Array<IssueUser> | null; /** 议题所属里程碑 */ milestone: MilestoneType | null; /** 关闭时间 */ closed_at: string | null; /** 创建时间 */ created_at: string; /** 更新时间 */ updated_at: string; } /** 议题列表参数类型 */ interface RepoIssueListParamType extends RepoBaseParamType { /** * 里程碑筛选 * @default * * - 传入数字时:按里程碑编号筛选 * - 传入 "*":接受任何里程碑的议题 * - 传入 "none":返回没有里程碑的议题 */ milestone?: string | number; /** * 议题状态 * @default "open" * - open: 打开的议题 * - closed: 关闭的议题 * - all: 所有议题 */ state?: 'all' | 'open' | 'closed'; /** * 指派人用户名 * - 传入用户名:返回指派给该用户的议题 * - 传入 "none":返回所有的议题 * - 传入用户名:返回指派给该用户的议题 * - 传入 "*":返回已指派给任何用户的议题 */ assignee?: string; /** * 议题类型 * - 传入类型名:返回指定类型的议题 * - 传入 "*":接受任何类型的议题 * - 传入 "none":返回没有类型的议题 */ type?: string; /** 创建者用户名,筛选由特定用户创建的议题 */ creator?: string; /** * 标签列表 * 以逗号分隔的标签名称列表 * @example "bug,ui,@high" */ labels?: string; /** * 排序方式 * @default "created" * - created: 按创建时间排序 * - updated: 按更新时间排序 * - comments: 按评论数排序 */ sort?: 'created' | 'updated' | 'comments'; /** * 排序方向 * @default "desc" * - asc: 升序 * - desc: 降序 */ direction?: 'asc' | 'desc'; /** * 筛选此时间之后更新的议题 * 仅显示在指定时间之后更新的结果 * 格式为 ISO 8601: YYYY-MM-DDTHH:MM:SSZ * @example "2023-01-01T00:00:00Z" */ since?: string; /** * 每页结果数量 * @default 30 * @remarks 取值范围:1-100 */ per_page?: number; /** * 页码 * @default 1 */ page?: number; } /** 议题列表响应类型 */ type IssueListResponseType = IssueInfoResponseType[]; /** 创建议题参数类型 */ type CreteIssueParamType = RepoBaseParamType & { /** 标题 */ title: string; /** 正文内容 */ body?: string | null; /** 里程碑 */ milestone?: number | string | null; /** 标签列表 */ labels?: Array<string> | string | null; /** 指派的用户名 */ assignees?: Array<string> | string | null; }; /** 创建议题响应类型 */ type CreateIssueResponseType = IssueInfoResponseType; /** 更新议题参数类型 */ interface UpdateIssueParamType extends Omit<CreteIssueParamType, 'title' | 'type'>, IssueNumberParamType { /** 问题的名称 */ title?: string | null; /** 问题的内容 */ body?: string | null; /** 问题的状态:open/closed */ state?: 'open' | 'closed'; } /** 更新议题响应类型 */ type UpdateIssueResponseType = IssueInfoResponseType; /** 打开议题参数类型 */ type OpenIssueParamType = RepoBaseParamType & IssueNumberParamType; /** 打开议题响应类型 */ type OpenIssueResponseType = IssueInfoResponseType; /** 关闭议题参数类型 */ type CloseIssueParamType = OpenIssueParamType; /** 关闭议题响应类型 */ type CloseIssueResponseType = IssueInfoResponseType; /** 锁定议题参数类型 */ interface LockIssueParamType extends RepoBaseParamType, IssueNumberParamType { /** * 锁定原因 * 可以是以下之一: * - off-topic:锁定议题,因为该议题与仓库无关 * - too heated:锁定议题,因为讨论过于激烈 * - resolved:锁定议题,因为该议题已解决 * - spam:锁定议题,因为该议题是垃圾邮件 */ lock_reason?: 'off-topic' | 'too heated' | 'resolved' | 'spam'; } /** 锁定议题响应类型 */ interface LockIssueResponseType { /** 是否成功锁定 */ success: boolean; /** 锁定状态信息 */ message: string; } /** 解锁议题参数类型 */ type UnLockIssueParamType = Omit<LockIssueParamType, 'lock_reason'>; /** 解锁议题响应类型 */ interface UnLockIssueResponseType { /** 是否成功解锁 */ success: LockIssueResponseType['success']; /** 解锁状态信息 */ message: LockIssueResponseType['message']; } /** 议题评论信息参数类型 */ type IssueCommentInfoParamType = RepoBaseParamType & CommentIdParamType; /** 议题评论信息响应类型 */ interface IssueCommentInfoResponseType { /** 评论ID */ id: number; /** 评论HTML页面URL */ html_url: string; /** 评论内容 */ body: string; /** 评论用户信息 */ user: IssueUser; /** 创建时间 */ created_at: string; /** 更新时间 */ updated_at: string; } /** 仓库评论列表参数类型 */ interface RepoCommentsListParamType extends RepoBaseParamType { /** * 排序依据 * 用于指定结果的排序属性 * @default created * - created: 按创建时间排序 * - updated: 按更新时间排序 */ sort?: 'created' | 'updated'; /** * 排序方向 * 指定结果的排序方向 * 注意:如果没有指定 sort 参数,此参数将被忽略 * @default desc 当 sort 参数存在时 * - asc: 升序 * - desc: 降序 */ direction?: 'asc' | 'desc'; /** * 筛选此时间之后更新的评论 * 仅显示在指定时间之后更新的结果 * 格式为 ISO 8601: YYYY-MM-DDTHH:MM:SSZ * @example "2023-01-01T00:00:00Z" */ since?: string; /** * 每页结果数量 * 指定每页返回的结果数 * @default 30 * @remarks 取值范围:1-100 */ per_page?: number; /** * 页码 * 指定要获取的结果页码 * @default 1 * @remarks 必须大于等于1 */ page?: number; } /** 仓库评论列表响应类型 */ type RepoCommentsListResponseType = IssueCommentInfoResponseType[]; /** 议题评论列表参数类型 */ interface IssueCommentsListParamType extends RepoBaseParamType { /** 议题ID */ issue_number: IssueNumberParamType['issue_number']; /** * 筛选此时间之后更新的评论 * 仅显示在指定时间之后更新的结果 * 格式为 ISO 8601: YYYY-MM-DDTHH:MM:SSZ * @example "2023-01-01T00:00:00Z" */ since?: string; /** * 每页结果数量 * @default 30 * @remarks 取值范围:1-100 */ per_page?: number; /** * 页码 * @default 1 * @remarks 取值范围:1-100 */ page?: number; } /** 议题评论列表响应类型 */ type IssueCommentsListResponseType = IssueCommentInfoResponseType[]; /** 创建议题评论参数类型 */ interface CreteIssueCommentParamType extends RepoBaseParamType { /** 议题ID */ issue_number: IssueNumberParamType['issue_number']; /** 评论内容 */ body: string; } /** 创建议题评论响应类型 */ type CreteIssueCommentResponseType = IssueCommentInfoResponseType; /** 更新议题评论参数类型 */ interface UpdateIssueCommentParamType extends IssueCommentInfoParamType { /** 评论内容 */ body: string; } /** 更新议题评论响应类型 */ type UpdateIssueCommentResponseType = IssueCommentInfoResponseType; /** 删除议题评论参数类型 */ interface RemoveIssueCommentParamType extends RepoBaseParamType { /** 评论ID */ comment_id: string | number; } /** 删除议题评论响应类型 */ interface RemoveIssueCommentResponseType { /** 是否成功删除议题 */ success: boolean; /** 删除状态信息 */ message: string; } /** 获取子议题列表参数类型 */ interface SubIssueListParamType extends RepoBaseParamType { /** 议题ID */ issue_number: IssueNumberParamType['issue_number']; /** * 每页结果数量 * @default 30 */ per_page?: number; /** * 页码 * @default 1 */ page?: number; } /** 获取子议题列表响应类型 */ type SubIssueListResponseType = IssueInfoResponseType[]; /** 添加子议题参数类型 */ interface CreateSubIssueParamType extends RepoBaseParamType { /** 议题ID */ issue_number: IssueNumberParamType['issue_number']; /** * 子议题ID */ sub_issue_id: IssueNumberParamType['issue_number']; /** * 是否替换父议题 */ replace_parent: boolean; } /** 添加子议题响应类型 */ type CreateSubIssueResponseType = IssueInfoResponseType; /** 删除子议题参数类型 */ interface RemoveSubIssueParamType extends RepoBaseParamType { /** 议题ID */ issue_number: IssueNumberParamType['issue_number']; /** 子议题ID */ sub_issue_id: IssueNumberParamType['issue_number']; } /** 删除子议题响应类型 */ type RemoveSubIssueResponseType = IssueInfoResponseType; /** 重新确定子议题优先级参数类型 */ interface ReprioritizeSubIssueParamType extends RepoBaseParamType { /** 议题ID */ issue_number: IssueNumberParamType['issue_number']; /** 子议题ID */ sub_issue_id: IssueNumberParamType['issue_number']; /** * 要优先排序的子问题的 ID(与 before_id 互斥,只能指定其中一个) * 在此 ID 之后放置子问题 */ after_id?: IssueNumberParamType['issue_number']; /** * 要优先排序的子问题的 ID(与 after_id 互斥,只能指定其中一个) * 在此 ID 之前放置子问题 */ before_id?: IssueNumberParamType['issue_number']; } /** 重新确定子议题优先级响应类型 */ type ReprioritizeSubIssueResponseType = IssueInfoResponseType; type OrgUser = Pick<UserInfoResponseType, 'id' | 'login' | 'name' | 'avatar_url' | 'html_url'>; /** 组织信息参数类型 */ type OrgInfoParamType = OrgNameParamType; /** 组织信息响应类型 */ interface OrgInfoResponseType { /** 组织ID */ id: number; /** 组织名称 */ login: string; /** 组织昵称 */ name: string; /** 组织头像 */ avatar_url: string; /** 组织描述 */ description: string; /** 组织地址 */ html_url: string; } /** 添加组织成员参数类型 */ interface AddMemberParamType extends OrgNameParamType, UserNameParamType { /** * 角色 */ role?: RoleNameType['role']; } /** 添加组织成员响应类型 */ interface AddMemberResponseType extends Omit<AddCollaboratorResponseType, 'permissions' | 'html_url'> { /** 组织地址 */ html_url: string; /** 角色 */ role: RoleNameType['role']; } /** 获取组织成员信息参数类型 */ type GetOrgMemberInfoParamType = OrgNameParamType & UserNameParamType; /** 获取组织成员信息响应类型 */ interface GetOrgMemberInfoResponseType { /** * 成员状态 * - active: 已激活 * - pending: 待处理 */ state: 'active' | 'pending'; /** * 成员角色 * - admin: 管理员 * - member: 成员 */ role: RoleNameType['role']; /** 组织信息 */ organization: Pick<OrgInfoResponseType, 'id' | 'login' | 'name' | 'html_url'>; /** 成员信息 */ user: OrgUser; } /** 获取组织成员列表参数 */ interface GetOrgMemberListParamType extends OrgNameParamType { /** 每页数量 */ per_page: number; /** 页码 */ page: number; } interface GetOrgMemberListType extends OrgUser { /** 角色 */ role: RoleNameType['role']; } /** 获取组织成员列表的响应类型 */ type GetOrgMemberListResponseType = Array<GetOrgMemberListType>; /** 移除组织成员参数类型 */ type RemoveOrgMemberParamType = OrgNameParamType & UserNameParamType; /** 移除组织成员响应类型 */ interface RemoveOrgMemberResponseType { /** 是否成功 */ success: boolean; /** 移除组织成员信息 */ message: string; } type PrUser = Pick<UserInfoResponseType, 'id' | 'login' | 'name' | 'avatar_url' | 'html_url'>; type PrRepo = Pick<RepoInfoResponseType, 'id' | 'owner' | 'name' | 'full_name'>; /** 拉取请求信息参数类型 */ type PullRequestInfoParamType = PullRequestNumberParamType & RepoBaseParamType; /** 拉取请求信息响应类型 */ interface PullRequestInfoResponseType { /** 拉取请求的id */ id: number; /** 拉取请求的URL */ html_url: string; /** 拉取请求的编号 */ number: number; /** 拉取请求的状态 (open/closed) */ state: 'open' | 'closed' | 'merged'; /** 是否被锁定 */ locked: boolean; /** 拉取请求的标题 */ title: string; /** 拉取请求的描述 */ body: string | null; /** 是否为草稿PR */ draft: boolean; /** 创建时间 */ created_at: string; /** 更新时间 */ updated_at: string | null; /** 关闭时间 */ closed_at: string | null; /** 合并时间 */ merged_at: string | null; /** PR作者 */ user: PrUser; /** PR的目标分支 */ base: { /** 分支标签 */ label: string; /** 分支名称 */ ref: string; /** 当前分支最新提交的 SHA 值 */ sha: string; /** 分支的用户信息 */ user: PrUser; /** 分支的仓库信息 */ repo: PrRepo; }; /** PR的源分支信息 */ head: { /** 分支标签 */ label: string; /** 分支名称 */ ref: string; /** 当前分支最新提交的 SHA 值 */ sha: string; /** 分支的用户信息 */ user: PrUser; /** 分支的仓库信息 */ repo: PrRepo; }; /** 指派人 */ assignee: PrUser | null; /** 指派人列表 */ assignees: Array<PrUser> | null; /** 里程碑 */ milestone: MilestoneType | null; /** 标签列表 */ labels: Array<IssueLabelType>; /** 提交数量 */ commits: number; /** 新增行数 */ additions: number; /** 删除行数 */ deletions: number; /** 更改的文件数 */ changed_files: number; } /** 拉取请求列表参数类型 */ interface PullRequestListParamType extends RepoBaseParamType { /** * 拉取请求状态 * @default "open" * - open: 打开的拉取请求 * - closed: 已关闭的拉取请求 * - all: 所有拉取请求 */ state?: 'open' | 'closed' | 'all'; /** * 基础分支名称 * 用于筛选指定目标分支的拉取请求 * @example "main" */ base?: string; /** * 排序依据 * @default "created" * - created: 按创建时间排序 * - updated: 按更新时间排序 */ sort?: 'created' | 'updated'; /** * 排序方向 * @default "desc" * - asc: 升序 * - desc: 降序 */ direction?: 'asc' | 'desc'; /** * 每页结果数量 * @default "30" * @remarks 取值范围:1-100 */ per_page?: string; /** * 页码 * @default "1" * @remarks 必须大于等于1 */ page?: string; } /** 拉取请求列表响应类型 */ type PullRequestListResponseType = Array<PullRequestInfoResponseType>; /** 使用issue填充拉取提交标题与内容 */ type WithIssue = { /** 拉取请求标题 */ title?: never; /** 拉取请求描述 */ body?: never; /** * 关联的议题 * Pull Request的标题和内容可以根据指定的Issue Id自动填充 */ issue: string | number; }; /** 不使用issue填充拉取提交标题与内容 */ type WithoutIssue = { /** 拉取请求标题 */ title: string; /** 拉取请求描述 */ body?: string; /** * 关联的议题 * Pull Request的标题和内容可以根据指定的Issue Id自动填充 */ issue?: never; }; /** 创建拉取提交参数类型 */ type CreatePullRequestParamType = RepoBaseParamType & (WithIssue | WithoutIssue) & { /** 拉取请求源分支 */ head: string; /** * 拉取请求源仓库 * 。如果两个存储库都由同一组织拥有,则跨存储库拉取请求需要此字段 * */ head_repo?: string; /** 拉取请求目标分支 */ base: string; /** 是否为草稿 */ draft?: boolean; }; /** 创建拉取请求响应类型 */ type CreatePullRequestResponseType = PullRequestInfoResponseType; /** 更新拉取请求参数类型 */ interface UpdatePullRequestParamType extends RepoBaseParamType, PullRequestNumberParamType { /** 拉取请求标题 */ title?: string; /** 拉取请求内容 */ body?: string; /** 拉取请求状态 */ state?: 'open' | 'closed'; } /** 更新拉取请求响应类型 */ type UpdatePullRequestResponseType = PullRequestInfoResponseType; /** * 合并拉取请求方式类型 * merge: 合并提交 * squash: 压缩提交 * rebase: 变基提交 */ type MergeMethodType = 'merge' | 'squash' | 'rebase'; /** 合并拉取请求参数类型 */ interface MergePullRequestParamType extends RepoBaseParamType, PullRequestNumberParamType { /** 拉取请求合并提交信息 */ commit_title?: string; /** 拉取请求合并提交信息 */ commit_message?: string; /** * 拉取请求合并SHA值 * 拉取请求头部必须匹配的 SHA 才能允许合并 * */ sha?: string; /** * 拉取请求合并方式 * @default merge * merge: 合并提交 * squash: 压缩提交 * rebase: 变基提交 * */ merge_method?: MergeMethodType; } /** * 合并拉取请求响应类型 * 对应 GitHub API 返回的 Pull Request Merge Result 结构 */ interface MergePullRequestResponseType { /** * 合并后的提交 SHA 值 * 表示合并操作生成的提交哈希 */ sha: string; /** * 是否成功合并 * - true: 成功合并 * - false: 合并失败或冲突 */ merged: boolean; /** * 合并结果描述信息 * 包含成功或失败的具体原因 */ message: string; } /** 文件列表类型 */ interface PullRequestFilesListType { /** 文件的SHA值 */ sha: string; /** 文件路径 */ filename: string; /** 文件状态 */ status: 'added' | 'removed' | 'modified' | 'renamed' | 'changed' | 'unchanged'; /** 文件添加行数 */ additions: number; /** 文件删除行数 */ deletions: number; /** 文件修改行数 */ changes: number; /** 文件的blob SHA值 */ blob_url: string; /** 文件的raw URL */ raw_url: string; /** 文件的patch内容, 也就是diff差异内容 */ patch: string; } /** 获取拉取请求文件列表参数类型 */ interface GetPullRequestFilesListParamType extends RepoBaseParamType, PullRequestNumberParamType { /** 每页结果数量 */ per_page?: string; /** 页码 */ page?: string; } /** 获取拉取请求文件列表响应类型 */ type GetPullRequestFilesListResponseType = Array<PullRequestFilesListType>; /** 获取拉取请求评论信息参数类型 */ type GetPullRequestCommentInfoParamType = RepoBaseParamType & CommentIdParamType; /** 获取拉取请求评论信息响应类型 */ interface GetPullRequestCommentInfoResponseType { /** 评论ID */ id: CommentIdParamType['comment_id']; /** 评论内容 */ body: string; /** 评论用户 */ user: PrUser; /** 评论创建时间 */ created_at: string; /** 评论更新时间 */ updated_at: string; } /** 获取拉取请求评论列表参数类型 */ interface GetPullRequestCommentsListParamType extends RepoBaseParamType, PullRequestNumberParamType { direction: 'asc' | 'desc'; /** 每页结果数量 */ per_page?: string; /** 页码 */ page?: string; } /** 获取拉取请求评论列表响应类型 */ type GetPullRequestCommentsListResponseType = Array<GetPullRequestCommentInfoResponseType>; /** 创建拉取请求评论参数类型 */ interface CreatePullRequestCommentParamType extends RepoBaseParamType, PullRequestNumberParamType { /** 评论内容 */ body: string; } /** 创建拉取请求评论响应类型 */ interface CreatePullRequestCommentResponseType { /** 评论id */ id: CommentIdParamType['comment_id']; /** 评论内容 */ body: string; } /** 更新拉取请求评论参数类型 */ interface UpdatePullRequestCommentParamType extends RepoBaseParamType, CommentIdParamType { /** 评论内容 */ body: string; } /** 更新拉取请求评论响应类型 */ interface UpdatePullRequestCommentResponseType { /** 是否更新评论信息成功 */ success: boolean; /** 更新评论状态信息 */ message: string; } /** 删除拉取请求评论参数类型 */ type DeletePullRequestCommentParamType = RepoBaseParamType & CommentIdParamType; /** 删除拉取请求评论响应类型 */ interface DeletePullRequestCommentResponseType { /** 是否删除成功 */ success: boolean; /** 删除状态信息 */ message: string; } type ReleaseUser = Omit<UserInfoResponseType, 'bio' | 'blog' | 'followers' | 'following' | 'public_repos' | 'email'>; /** 反应信息类型 */ interface ReactionInfoType { /** 反应 API URL */ url: string; /** 总反应数 */ total_count: number; /** 👍 反应数 */ '+1': number; /** 👎 反应数 */ '-1': number; /** 😄 反应数 */ laugh: number; /** 😕 反应数 */ confused: number; /** ❤️ 反应数 */ heart: number; /** 🎉 反应数 */ hooray: number; /** 👀 反应数 */ eyes: number; /** 🚀 反应数 */ rocket: number; } /** 发布资源类型 */ interface ReleaseAssetsType { /** 资源 URL */ url: string; /** 资源下载 URL */ browser_download_url: string; } /** 获取Release信息参数类型 */ type ReleaseInfoParamType = RepoBaseParamType & { /** 发布ID */ release_id: number; }; /** 获Release信息响应类型 */ interface ReleaseInfoResponseType { /** * 发布版本的 ID * 该字段在gitcode平台为null */ id: number | null; /** 标签名称 */ tag_name: string; /** 目标分支或提交 */ target_commitish: string; /** 发布版本名称 */ name: string | null; /** 发布说明 */ body: string | null; /** 是否为预发布版本 */ prerelease: boolean; /** 发布者信息 */ author: ReleaseUser; /** 发布资源列表 */ assets: Array<ReleaseAssetsType>; /** 发布时间 */ created_at: string; } /** 获取最新Release参数类型 */ type ReleaseLatestParamTypeType = RepoBaseParamType; /** 获取最新Release响应类型 */ type ReleaseLatestResponseType = ReleaseInfoResponseType; /** 通过Tag获取Release信息参数类型 */ type ReleaseInfoByTagParamType = RepoBaseParamType & { /** 标签名称 */ tag: string; }; /** 通过Tag获取Release信息响应类型 */ type ReleaseInfoByTagResponseType = ReleaseInfoResponseType; /** 获取Release列表参数类型 */ type ReleaseListParamType = RepoBaseParamType & { /** 每页数量 */ per_page?: number; /** 页码 */ page?: number; }; /** 获取Release列表响应类型 */ type ReleaseListResponseType = Array<ReleaseInfoResponseType>; /** 创建Release参数类型 */ type CreateReleaseParamType = RepoBaseParamType & { /** 标签名称 */ tag_name: string; /** 目标分支或提交 */ target_commitish: string; /** 发布版本名称 */ name: string; /** 发布说明 */ body: string; /** 是否为预发布版本 */ prerelease: boolean; }; /** 获取Release列表参数类型 */ type CreateReleaseResponseType = ReleaseInfoResponseType; /** 更新Release参数类型 */ type UpdateReleaseParamType = CreateReleaseParamType; /** 更新Release响应类型 */ type UpdateReleaseResponseType = ReleaseInfoResponseType; /** 删除Release参数类型 */ type DeleteReleaseParamType = ReleaseInfoParamType; /** 删除Release响应类型 */ interface DeleteReleaseResponseType { /** 是否删除成功 */ success: boolean; /** 删除状态信息 */ message: string; } type SearchUser = Pick<UserInfoResponseType, 'id' | 'login' | 'name' | 'avatar_url' | 'html_url' | 'email'>; type SearchRepo = Pick<RepoInfoResponseType, 'id' | 'owner' | 'name' | 'full_name' | 'description' | 'visibility' | 'public' | 'private' | 'archived' | 'language' | 'pushed_at'>; /** 搜索用户参数列表 */ interface SearchUsersParamType { /** 搜索关键字 */ q: string; /** 排序顺序 */ order: 'desc' | 'asc'; /** 每页数量 */ per_page?: number; /** 页码 */ page?: number; } /** 搜索用户响应列表 */ interface SearchUsersResponseType { /** 搜索结果数量 */ total_count: number; /** 用户列表 */ items: Array<SearchUser>; } interface SearchReposParamType { /** 搜索关键字 */ q: string; /** 排序顺序 */ order: 'desc' | 'asc'; /** 每页数量 */ per_page?: number; /** 页码 */ page?: number; } interface SearchReposResponseType { /** 搜索结果数量 */ total_count: number; /** 用户列表 */ items: Array<SearchRepo>; } interface WebHookSignatureParamType { /** 请求体 */ payload: string; /** GitHub 发送的签名头 */ signature: string; } interface WebHookSignatureResponseType { /** 是否验证成功 */ success: boolean; /** 验证信息 */ message: string; } /** * 获取本地 Git 仓库信息 * @description 获取本地 Git 仓库信息,返回仓库名称、仓库路径、仓库地址等信息 * @param local_path - 本地仓库路径 * @returns Git 仓库信息 * @example * ```ts * const info = await get_local_git_repo_info('D:/project/repo') * console.log(info) * -> { * name: 'repo', * path: 'D:/project/repo', * url: 'https://github.com/owner/repo.git', * html_url: 'https://github.com/owner/repo', * owner: 'owner', * repo: 'repo' * } * ``` */ declare function get_local_git_repo_info(local_path: string): Promise<GitRepoInfoType | null>; /** * 获取本地仓库信息列表 * @param local_path 本地仓库路径 * @param options 配置项 * - loop 是否递归查找 * - maxDepth 递归最大深度 * - dir 忽略的文件夹名称列表 * @returns LocalGitInfoListType 仓库信息列表 * @example * ```ts * // 无数据 * const res = await get_local_git_repo_list('D:\\project\\GitHub', { loop: true, maxDepth: 5, dir: ['node_modules'] }) * -> { * total: 0, * items: [] * } * * // 有数据 * const res = await get_local_git_repo_list('D:\\project\\GitHub', { loop: true, maxDepth: 5, dir: ['node_modules'] }) * -> { * total: 1, * items: [{ * name: "GitHub", * path: "D:\\project\\GitHub\\GitHub", * url: "https://github.com/GitHub/GitHub.git", * html_url: "https://github.com/GitHub/GitHub", * owner: "GitHub", * repo: "GitHub" * }] * } * ``` */ declare function get_local_git_repos_list(dirpath: string, options?: GitRepoInfoListOptionsType): Promise<GitInfoListType>; /** * 获取本地仓库的默认分支 * @param local_path - 本地仓库路径 * @returns 默认分支名称 * @example * ```ts * console.log(await get_local_repo_default_branch('/path/to/repo')) * -> 'main' * ``` */ declare function get_local_repo_default_branch(local_path: string): Promise<string>; /** * 获取远程仓库的默认分支 * @param remote_url - 远程仓库URL * @returns 默认分支名称 * @example * ```ts * console.log(await get_remote_repo_default_branch('https://github.com/CandriaJS/git-neko-kit')) * -> 'main' * ``` */ declare function get_remote_repo_default_branch(remote_url: string): Promise<string>; /** * 渲染 markdown 内容为 HTML * @description 使用配置好的 markdown-it 实例渲染 markdown 内容 * @param md - 要渲染的 markdown 字符串 * @returns 渲染后的 HTML 字符串 * @example * ```ts * const html = await render_markdown(`# 标题 * - 无序列表项1 * - 无序列表项2 * - 子列表项 * * 1. 有序列表项1 * 2. 有序列表项2 * `); * * // 输出结果: * // <h1>标题</h1> * // <ul style="list-style: none;"> * // <li>无序列表项1</li> * // <li>无序列表项2</li> * // <ul style="list-style: none;"> * // <li>子列表项</li> * // </ul> * // </ul> * // <ol style="list-style: none;"> * // <li>有序列表项1</li> * // <li>有序列表项2</li> * // </ol> * ``` */ declare function render_markdown(md: string): Promise<string>; /** * 获取本地 NPM 包信息 * @des