commit a4dbedcd69a8dab7f70af7125a58c9c9a897ae15 Author: monoid Date: Fri Mar 24 01:40:08 2023 +0900 init diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..688ed45 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "deno.enable": true, + "deno.unstable": true, + "deno.suggest.imports.hosts": { + "https://deno.land": true, + "https://x.nest.land": true, + "https://crux.land": true, + "http://localhost:9999": true + } +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..14ab53d --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2023 monoid + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6e53d44 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Simple deno import intellisense proxy for gitea + +This is a simple proxy server for gitea. It is used to proxy requests to gitea from a subpath. +It implements import completion for deno. +Details can be found in the [deno docs](https://deno.land/manual@v1.32.0/advanced/language_server/imports). + +## Usage + +```bash +deno run --allow-net app.ts +``` diff --git a/app.ts b/app.ts new file mode 100644 index 0000000..2814743 --- /dev/null +++ b/app.ts @@ -0,0 +1,149 @@ +import { Application, Router } from "https://deno.land/x/oak@v12.1.0/mod.ts"; +import { + searchRepositoryWithTopic, + getRepositoryTags, + getRepositoryContent +} from "./gitea.ts"; +import { ContentsResponse } from "./gitea_api.d.ts"; +import { Command } from "https://deno.land/x/cliffy@v0.25.7/mod.ts"; + +// import { load } from "https://deno.land/std@0.181.0/dotenv/mod.ts"; +// const env = await load(); + +const app = new Application(); +const router = new Router(); + +const RelativeTopic = "denolib"; + +export interface CompletionList { + /** The list (or partial list) of completion items. */ + items: string[]; + /** If the list is a partial list, and further queries to the endpoint will + * change the items, set `isIncomplete` to `true`. */ + isIncomplete?: boolean; + /** If one of the items in the list should be preselected (the default + * suggestion), then set the value of `preselect` to the value of the item. */ + preselect?: string; +} + +router.get("/.well-known/deno-import-intellisense.json", (ctx) => { + console.log("get /.well-known/deno-import-intellisense.json"); + ctx.response.type = "application/json"; + ctx.response.body = { + "version": 2, + "registries": [ + { + "schema": "/:package([a-z0-9_]*@[a-z0-9_]*)/:version?/:path*", + "variables": [ + { + "key": "package", + // "documentation": "/docs/packages/${package}", + "url": "/packages/${package}" + }, + { + "key": "version", + "url": "/packages/${package}/versions" + }, + { + "key": "path", + // "documentation": "/docs/packages/${package}/${{version}}/paths/${path}", + "url": "/packages/${package}/${{version}}/paths/${path}" + } + ] + } + ] + }; +}); + +router.get("/packages/:package", async (ctx) => { + const packageName = ctx.params.package; + console.log(`searchRepositoryWithTopic: ${packageName}`); + const repositories = await searchRepositoryWithTopic(RelativeTopic); + const repo_name = repositories.data?.map((repo) => repo.full_name) + .filter(x => x !== undefined) + .map(x=> x?.replace("/","@")) ?? []; + const completionList: CompletionList = { + items: repo_name as string[], + isIncomplete: true, // TODO: check if there are more than max results + preselect: repo_name[0] + }; + ctx.response.type = "application/json"; + ctx.response.body = completionList; +}); + +router.get("/packages/:package/versions", async (ctx) => { + const packageName = ctx.params.package; + const [owner, repo] = packageName.split("@"); + console.log(`getTags: owner: ${owner}, repo: ${repo}`); + const tags = await getRepositoryTags(owner, repo); + const candidate = ["main", ...tags.map((tag) => tag.name) as string[]] + const completionList: CompletionList = { + items: candidate, + isIncomplete: false, + preselect: candidate[0] + }; + ctx.response.type = "application/json"; + ctx.response.body = completionList; +}); + +router.get("/packages/:package/:version/paths/:path*", async (ctx) => { + const packageName = ctx.params.package; + const version = ctx.params.version; + const path = ctx.params.path; + const [owner, repo] = packageName.split("@"); + console.log(`getFilesEntry: owner: ${owner}, repo: ${repo}, path: ${path}, version: ${version}`); + const entries = await getRepositoryContent(owner, repo, path ?? "", version) as ContentsResponse[]; + const completionList: CompletionList = { + items: entries.map((entry) => entry.name) as string[], + isIncomplete: false, + preselect: entries[0].name + }; + ctx.response.type = "application/json"; + ctx.response.body = completionList; +}); + +router.get("/:package([a-z0-9_]*@[a-z0-9_]*)/:version?/:path*", async (ctx) => { + const packageName = ctx.params.package; + const [owner, repo] = packageName.split("@"); + const version = ctx.params.version; + const path = ctx.params.path; + console.log(`getFiles: owner: ${owner}, repo: ${repo}, path: ${path}, version: ${version}`); + const entries = await getRepositoryContent(owner, repo, path ?? "", version); + if (entries instanceof Array) { + ctx.response.type = "application/json"; + ctx.response.body = entries; + } + else { + if ("errors" in entries){ + ctx.throw(404); + } + // TODO: check if the file is text file or not (e.g. image) + ctx.response.type = "text/plain"; + ctx.response.body = atob(entries.content ?? ""); + } +}); + + +app.use(router.routes()); +app.use(router.allowedMethods()); + +//app.use(async (ctx, next) => { +// ctx.throw(404); +// //ctx.response.status = 404; +// //ctx.response.body = "Not Found"; +// //await next(); +//}); +app.addEventListener("listen", ({ hostname, port, secure }) => { + console.log(`🚀 Listening on: ${secure ? "https://" : "http://"}${hostname ?? "localhost"}:${port}`); +}); + +if (import.meta.main) { + const cmd = new Command() + .version("0.1.0") + .description("Simple Deno import intellisense proxy server for Gitea") + .option("-p, --port ", "Port number to listen on", { default: 9999 }) + .action(async ({ port }) => { + await app.listen({ port: port }); + }); + await cmd.parse(Deno.args); +} diff --git a/gitea.ts b/gitea.ts new file mode 100644 index 0000000..1fa7b43 --- /dev/null +++ b/gitea.ts @@ -0,0 +1,36 @@ +import { SearchResults, Tag, ContentsResponse } from "./gitea_api.d.ts"; + +const ENDPOINT_URL = "https://git.prelude.duckdns.org/api/v1/"; + +export async function searchRepositoryWithTopic(topic: string): Promise { + const url = new URL(ENDPOINT_URL+ "repos/search"); + url.searchParams.append("q", topic); + url.searchParams.append("topic", "true"); + const response = await fetch(url); + const data = await response.json(); + return data; +} + +export async function getRepositoryTags(owner:string, + repo:string): Promise{ + const url = new URL(ENDPOINT_URL+ "repos/"+owner+"/"+repo+"/tags"); + const response = await fetch(url); + const data = await response.json(); + return data; +} + +export async function getRepositoryContent(owner:string, + repo:string, path:string, ref:string): Promise{ + const url = new URL(ENDPOINT_URL+ "repos/"+owner+"/"+repo+"/contents/"+path); + url.searchParams.append("ref", ref); + const response = await fetch(url); + const data = await response.json(); + return data; +} + +if (import.meta.main) { + const results = await searchRepositoryWithTopic("deno"); + console.log(results.data?.map((repo) => repo.full_name)); + const s = await getRepositoryContent("monoid", "script", "", ""); + console.log((s as ContentsResponse[]).map((x) => x.name)); +} \ No newline at end of file diff --git a/gitea_api.d.ts b/gitea_api.d.ts new file mode 100644 index 0000000..58ddcd2 --- /dev/null +++ b/gitea_api.d.ts @@ -0,0 +1,2338 @@ +/** + * APIError is an api error with a message + */ +export interface APIError { + message?: string; + url?: string; +} +/** + * AccessToken represents an API access token. + */ +export interface AccessToken { + id?: number; // int64 + name?: string; + scopes?: string[]; + sha1?: string; + token_last_eight?: string; +} +/** + * ActivityPub type + */ +export interface ActivityPub { + "@context"?: string; +} +/** + * AddCollaboratorOption options when adding a user as a collaborator of a repository + */ +export interface AddCollaboratorOption { + permission?: string; +} +/** + * AddTimeOption options for adding time to an issue + */ +export interface AddTimeOption { + created?: string; // date-time + /** + * time in seconds + */ + time: number; // int64 + /** + * User who spent the time (optional) + */ + user_name?: string; +} +/** + * AnnotatedTag represents an annotated tag + */ +export interface AnnotatedTag { + message?: string; + object?: AnnotatedTagObject; + sha?: string; + tag?: string; + tagger?: CommitUser; + url?: string; + verification?: PayloadCommitVerification; +} +/** + * AnnotatedTagObject contains meta information of the tag object + */ +export interface AnnotatedTagObject { + sha?: string; + type?: string; + url?: string; +} +/** + * Attachment a generic attachment + */ +export interface Attachment { + browser_download_url?: string; + created_at?: string; // date-time + download_count?: number; // int64 + id?: number; // int64 + name?: string; + size?: number; // int64 + uuid?: string; +} +/** + * Branch represents a repository branch + */ +export interface Branch { + commit?: PayloadCommit; + effective_branch_protection_name?: string; + enable_status_check?: boolean; + name?: string; + protected?: boolean; + required_approvals?: number; // int64 + status_check_contexts?: string[]; + user_can_merge?: boolean; + user_can_push?: boolean; +} +/** + * BranchProtection represents a branch protection for a repository + */ +export interface BranchProtection { + approvals_whitelist_teams?: string[]; + approvals_whitelist_username?: string[]; + block_on_official_review_requests?: boolean; + block_on_outdated_branch?: boolean; + block_on_rejected_reviews?: boolean; + /** + * Deprecated: true + */ + branch_name?: string; + created_at?: string; // date-time + dismiss_stale_approvals?: boolean; + enable_approvals_whitelist?: boolean; + enable_merge_whitelist?: boolean; + enable_push?: boolean; + enable_push_whitelist?: boolean; + enable_status_check?: boolean; + merge_whitelist_teams?: string[]; + merge_whitelist_usernames?: string[]; + protected_file_patterns?: string; + push_whitelist_deploy_keys?: boolean; + push_whitelist_teams?: string[]; + push_whitelist_usernames?: string[]; + require_signed_commits?: boolean; + required_approvals?: number; // int64 + rule_name?: string; + status_check_contexts?: string[]; + unprotected_file_patterns?: string; + updated_at?: string; // date-time +} +/** + * ChangedFile store information about files affected by the pull request + */ +export interface ChangedFile { + additions?: number; // int64 + changes?: number; // int64 + contents_url?: string; + deletions?: number; // int64 + filename?: string; + html_url?: string; + previous_filename?: string; + raw_url?: string; + status?: string; +} +/** + * CombinedStatus holds the combined state of several statuses for a single commit + */ +export interface CombinedStatus { + commit_url?: string; + repository?: Repository; + sha?: string; + state?: CommitStatusState; + statuses?: CommitStatus[]; + total_count?: number; // int64 + url?: string; +} +/** + * Comment represents a comment on a commit or issue + */ +export interface Comment { + assets?: Attachment[]; + body?: string; + created_at?: string; // date-time + html_url?: string; + id?: number; // int64 + issue_url?: string; + original_author?: string; + original_author_id?: number; // int64 + pull_request_url?: string; + updated_at?: string; // date-time + user?: User; +} +/** + * Commit contains information generated from a Git commit. + */ +export interface Commit { + author?: User; + commit?: RepoCommit; + committer?: User; + created?: string; // date-time + files?: CommitAffectedFiles[]; + html_url?: string; + parents?: CommitMeta[]; + sha?: string; + stats?: CommitStats; + url?: string; +} +/** + * CommitAffectedFiles store information about files affected by the commit + */ +export interface CommitAffectedFiles { + filename?: string; +} +/** + * CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE + */ +export interface CommitDateOptions { + author?: string; // date-time + committer?: string; // date-time +} +/** + * CommitMeta contains meta information of a commit in terms of API. + */ +export interface CommitMeta { + created?: string; // date-time + sha?: string; + url?: string; +} +/** + * CommitStats is statistics for a RepoCommit + */ +export interface CommitStats { + additions?: number; // int64 + deletions?: number; // int64 + total?: number; // int64 +} +/** + * CommitStatus holds a single status of a single Commit + */ +export interface CommitStatus { + context?: string; + created_at?: string; // date-time + creator?: User; + description?: string; + id?: number; // int64 + status?: CommitStatusState; + target_url?: string; + updated_at?: string; // date-time + url?: string; +} +/** + * CommitStatusState holds the state of a CommitStatus + * It can be "pending", "success", "error", "failure", and "warning" + */ +export type CommitStatusState = string; +/** + * CommitUser contains information of a user in the context of a commit. + */ +export interface CommitUser { + date?: string; + email?: string; // email + name?: string; +} +/** + * ContentsResponse contains information about a repo's entry's (dir, file, symlink, submodule) metadata and content + */ +export interface ContentsResponse { + _links?: FileLinksResponse; + /** + * `content` is populated when `type` is `file`, otherwise null + */ + content?: string; + download_url?: string; + /** + * `encoding` is populated when `type` is `file`, otherwise null + */ + encoding?: string; + git_url?: string; + html_url?: string; + last_commit_sha?: string; + name?: string; + path?: string; + sha?: string; + size?: number; // int64 + /** + * `submodule_git_url` is populated when `type` is `submodule`, otherwise null + */ + submodule_git_url?: string; + /** + * `target` is populated when `type` is `symlink`, otherwise null + */ + target?: string; + /** + * `type` will be `file`, `dir`, `symlink`, or `submodule` + */ + type?: string; + url?: string; +} +/** + * CreateAccessTokenOption options when create access token + */ +export interface CreateAccessTokenOption { + name: string; + scopes?: string[]; +} +/** + * CreateBranchProtectionOption options for creating a branch protection + */ +export interface CreateBranchProtectionOption { + approvals_whitelist_teams?: string[]; + approvals_whitelist_username?: string[]; + block_on_official_review_requests?: boolean; + block_on_outdated_branch?: boolean; + block_on_rejected_reviews?: boolean; + /** + * Deprecated: true + */ + branch_name?: string; + dismiss_stale_approvals?: boolean; + enable_approvals_whitelist?: boolean; + enable_merge_whitelist?: boolean; + enable_push?: boolean; + enable_push_whitelist?: boolean; + enable_status_check?: boolean; + merge_whitelist_teams?: string[]; + merge_whitelist_usernames?: string[]; + protected_file_patterns?: string; + push_whitelist_deploy_keys?: boolean; + push_whitelist_teams?: string[]; + push_whitelist_usernames?: string[]; + require_signed_commits?: boolean; + required_approvals?: number; // int64 + rule_name?: string; + status_check_contexts?: string[]; + unprotected_file_patterns?: string; +} +/** + * CreateBranchRepoOption options when creating a branch in a repository + */ +export interface CreateBranchRepoOption { + /** + * Name of the branch to create + */ + new_branch_name: string; + /** + * Name of the old branch to create from + */ + old_branch_name?: string; +} +/** + * CreateEmailOption options when creating email addresses + */ +export interface CreateEmailOption { + /** + * email addresses to add + */ + emails?: string[]; +} +/** + * CreateFileOptions options for creating files + * Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) + */ +export interface CreateFileOptions { + author?: Identity; + /** + * branch (optional) to base this file from. if not given, the default branch is used + */ + branch?: string; + committer?: Identity; + /** + * content must be base64 encoded + */ + content: string; + dates?: CommitDateOptions; + /** + * message (optional) for the commit of this file. if not supplied, a default message will be used + */ + message?: string; + /** + * new_branch (optional) will make a new branch from `branch` before creating the file + */ + new_branch?: string; + /** + * Add a Signed-off-by trailer by the committer at the end of the commit log message. + */ + signoff?: boolean; +} +/** + * CreateForkOption options for creating a fork + */ +export interface CreateForkOption { + /** + * name of the forked repository + */ + name?: string; + /** + * organization name, if forking into an organization + */ + organization?: string; +} +/** + * CreateGPGKeyOption options create user GPG key + */ +export interface CreateGPGKeyOption { + /** + * An armored GPG key to add + */ + armored_public_key: string; + armored_signature?: string; +} +/** + * CreateHookOption options when create a hook + */ +export interface CreateHookOption { + active?: boolean; + authorization_header?: string; + branch_filter?: string; + config: CreateHookOptionConfig; + events?: string[]; + type: "dingtalk" | "discord" | "gitea" | "gogs" | "msteams" | "slack" | "telegram" | "feishu" | "wechatwork" | "packagist"; +} +/** + * CreateHookOptionConfig has all config options in it + * required are "content_type" and "url" Required + */ +export interface CreateHookOptionConfig { + [name: string]: string; +} +/** + * CreateIssueCommentOption options for creating a comment on an issue + */ +export interface CreateIssueCommentOption { + body: string; +} +/** + * CreateIssueOption options to create one issue + */ +export interface CreateIssueOption { + /** + * deprecated + */ + assignee?: string; + assignees?: string[]; + body?: string; + closed?: boolean; + due_date?: string; // date-time + /** + * list of label ids + */ + labels?: number /* int64 */ []; + /** + * milestone id + */ + milestone?: number; // int64 + ref?: string; + title: string; +} +/** + * CreateKeyOption options when creating a key + */ +export interface CreateKeyOption { + /** + * An armored SSH key to add + */ + key: string; + /** + * Describe if the key has only read access or read/write + */ + read_only?: boolean; + /** + * Title of the key to add + */ + title: string; +} +/** + * CreateLabelOption options for creating a label + */ +export interface CreateLabelOption { + /** + * example: + * #00aabb + */ + color: string; + description?: string; + /** + * example: + * false + */ + exclusive?: boolean; + name: string; +} +/** + * CreateMilestoneOption options for creating a milestone + */ +export interface CreateMilestoneOption { + description?: string; + due_on?: string; // date-time + state?: "open" | "closed"; + title?: string; +} +/** + * CreateOAuth2ApplicationOptions holds options to create an oauth2 application + */ +export interface CreateOAuth2ApplicationOptions { + confidential_client?: boolean; + name?: string; + redirect_uris?: string[]; +} +/** + * CreateOrgOption options for creating an organization + */ +export interface CreateOrgOption { + description?: string; + full_name?: string; + location?: string; + repo_admin_change_team_access?: boolean; + username: string; + /** + * possible values are `public` (default), `limited` or `private` + */ + visibility?: "public" | "limited" | "private"; + website?: string; +} +/** + * CreatePullRequestOption options when creating a pull request + */ +export interface CreatePullRequestOption { + assignee?: string; + assignees?: string[]; + base?: string; + body?: string; + due_date?: string; // date-time + head?: string; + labels?: number /* int64 */ []; + milestone?: number; // int64 + title?: string; +} +/** + * CreatePullReviewComment represent a review comment for creation api + */ +export interface CreatePullReviewComment { + body?: string; + /** + * if comment to new file line or 0 + */ + new_position?: number; // int64 + /** + * if comment to old file line or 0 + */ + old_position?: number; // int64 + /** + * the tree path + */ + path?: string; +} +/** + * CreatePullReviewOptions are options to create a pull review + */ +export interface CreatePullReviewOptions { + body?: string; + comments?: CreatePullReviewComment[]; + commit_id?: string; + event?: ReviewStateType; +} +/** + * CreatePushMirrorOption represents need information to create a push mirror of a repository. + */ +export interface CreatePushMirrorOption { + interval?: string; + remote_address?: string; + remote_password?: string; + remote_username?: string; + sync_on_commit?: boolean; +} +/** + * CreateReleaseOption options when creating a release + */ +export interface CreateReleaseOption { + body?: string; + draft?: boolean; + name?: string; + prerelease?: boolean; + tag_name: string; + target_commitish?: string; +} +/** + * CreateRepoOption options when creating repository + */ +export interface CreateRepoOption { + /** + * Whether the repository should be auto-initialized? + */ + auto_init?: boolean; + /** + * DefaultBranch of the repository (used when initializes and in template) + */ + default_branch?: string; + /** + * Description of the repository to create + */ + description?: string; + /** + * Gitignores to use + */ + gitignores?: string; + /** + * Label-Set to use + */ + issue_labels?: string; + /** + * License to use + */ + license?: string; + /** + * Name of the repository to create + */ + name: string; + /** + * Whether the repository is private + */ + private?: boolean; + /** + * Readme of the repository to create + */ + readme?: string; + /** + * Whether the repository is template + */ + template?: boolean; + /** + * TrustModel of the repository + */ + trust_model?: "default" | "collaborator" | "committer" | "collaboratorcommitter"; +} +/** + * CreateStatusOption holds the information needed to create a new CommitStatus for a Commit + */ +export interface CreateStatusOption { + context?: string; + description?: string; + state?: CommitStatusState; + target_url?: string; +} +/** + * CreateTagOption options when creating a tag + */ +export interface CreateTagOption { + message?: string; + tag_name: string; + target?: string; +} +/** + * CreateTeamOption options for creating a team + */ +export interface CreateTeamOption { + can_create_org_repo?: boolean; + description?: string; + includes_all_repositories?: boolean; + name: string; + permission?: "read" | "write" | "admin"; + /** + * example: + * repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.projects,repo.ext_wiki + */ + units?: string[]; + /** + * example: + * [object Object] + */ + units_map?: { + [name: string]: string; + }; +} +/** + * CreateUserOption create user options + */ +export interface CreateUserOption { + /** + * For explicitly setting the user creation timestamp. Useful when users are + * migrated from other systems. When omitted, the user's creation timestamp + * will be set to "now". + */ + created_at?: string; // date-time + email: string; // email + full_name?: string; + login_name?: string; + must_change_password?: boolean; + password: string; + restricted?: boolean; + send_notify?: boolean; + source_id?: number; // int64 + username: string; + visibility?: string; +} +/** + * CreateWikiPageOptions form for creating wiki + */ +export interface CreateWikiPageOptions { + /** + * content must be base64 encoded + */ + content_base64?: string; + /** + * optional commit message summarizing the change + */ + message?: string; + /** + * page title. leave empty to keep unchanged + */ + title?: string; +} +/** + * Cron represents a Cron task + */ +export interface Cron { + exec_times?: number; // int64 + name?: string; + next?: string; // date-time + prev?: string; // date-time + schedule?: string; +} +/** + * DeleteEmailOption options when deleting email addresses + */ +export interface DeleteEmailOption { + /** + * email addresses to delete + */ + emails?: string[]; +} +/** + * DeleteFileOptions options for deleting files (used for other File structs below) + * Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) + */ +export interface DeleteFileOptions { + author?: Identity; + /** + * branch (optional) to base this file from. if not given, the default branch is used + */ + branch?: string; + committer?: Identity; + dates?: CommitDateOptions; + /** + * message (optional) for the commit of this file. if not supplied, a default message will be used + */ + message?: string; + /** + * new_branch (optional) will make a new branch from `branch` before creating the file + */ + new_branch?: string; + /** + * sha is the SHA for the file that already exists + */ + sha: string; + /** + * Add a Signed-off-by trailer by the committer at the end of the commit log message. + */ + signoff?: boolean; +} +/** + * DeployKey a deploy key + */ +export interface DeployKey { + created_at?: string; // date-time + fingerprint?: string; + id?: number; // int64 + key?: string; + key_id?: number; // int64 + read_only?: boolean; + repository?: Repository; + title?: string; + url?: string; +} +/** + * DismissPullReviewOptions are options to dismiss a pull review + */ +export interface DismissPullReviewOptions { + message?: string; + priors?: boolean; +} +/** + * EditAttachmentOptions options for editing attachments + */ +export interface EditAttachmentOptions { + name?: string; +} +/** + * EditBranchProtectionOption options for editing a branch protection + */ +export interface EditBranchProtectionOption { + approvals_whitelist_teams?: string[]; + approvals_whitelist_username?: string[]; + block_on_official_review_requests?: boolean; + block_on_outdated_branch?: boolean; + block_on_rejected_reviews?: boolean; + dismiss_stale_approvals?: boolean; + enable_approvals_whitelist?: boolean; + enable_merge_whitelist?: boolean; + enable_push?: boolean; + enable_push_whitelist?: boolean; + enable_status_check?: boolean; + merge_whitelist_teams?: string[]; + merge_whitelist_usernames?: string[]; + protected_file_patterns?: string; + push_whitelist_deploy_keys?: boolean; + push_whitelist_teams?: string[]; + push_whitelist_usernames?: string[]; + require_signed_commits?: boolean; + required_approvals?: number; // int64 + status_check_contexts?: string[]; + unprotected_file_patterns?: string; +} +/** + * EditDeadlineOption options for creating a deadline + */ +export interface EditDeadlineOption { + due_date: string; // date-time +} +/** + * EditGitHookOption options when modifying one Git hook + */ +export interface EditGitHookOption { + content?: string; +} +/** + * EditHookOption options when modify one hook + */ +export interface EditHookOption { + active?: boolean; + authorization_header?: string; + branch_filter?: string; + config?: { + [name: string]: string; + }; + events?: string[]; +} +/** + * EditIssueCommentOption options for editing a comment + */ +export interface EditIssueCommentOption { + body: string; +} +/** + * EditIssueOption options for editing an issue + */ +export interface EditIssueOption { + /** + * deprecated + */ + assignee?: string; + assignees?: string[]; + body?: string; + due_date?: string; // date-time + milestone?: number; // int64 + ref?: string; + state?: string; + title?: string; + unset_due_date?: boolean; +} +/** + * EditLabelOption options for editing a label + */ +export interface EditLabelOption { + /** + * example: + * #00aabb + */ + color?: string; + description?: string; + /** + * example: + * false + */ + exclusive?: boolean; + name?: string; +} +/** + * EditMilestoneOption options for editing a milestone + */ +export interface EditMilestoneOption { + description?: string; + due_on?: string; // date-time + state?: string; + title?: string; +} +/** + * EditOrgOption options for editing an organization + */ +export interface EditOrgOption { + description?: string; + full_name?: string; + location?: string; + repo_admin_change_team_access?: boolean; + /** + * possible values are `public`, `limited` or `private` + */ + visibility?: "public" | "limited" | "private"; + website?: string; +} +/** + * EditPullRequestOption options when modify pull request + */ +export interface EditPullRequestOption { + allow_maintainer_edit?: boolean; + assignee?: string; + assignees?: string[]; + base?: string; + body?: string; + due_date?: string; // date-time + labels?: number /* int64 */ []; + milestone?: number; // int64 + state?: string; + title?: string; + unset_due_date?: boolean; +} +/** + * EditReactionOption contain the reaction type + */ +export interface EditReactionOption { + content?: string; +} +/** + * EditReleaseOption options when editing a release + */ +export interface EditReleaseOption { + body?: string; + draft?: boolean; + name?: string; + prerelease?: boolean; + tag_name?: string; + target_commitish?: string; +} +/** + * EditRepoOption options when editing a repository's properties + */ +export interface EditRepoOption { + /** + * either `true` to allow mark pr as merged manually, or `false` to prevent it. + */ + allow_manual_merge?: boolean; + /** + * either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. + */ + allow_merge_commits?: boolean; + /** + * either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. + */ + allow_rebase?: boolean; + /** + * either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits. + */ + allow_rebase_explicit?: boolean; + /** + * either `true` to allow updating pull request branch by rebase, or `false` to prevent it. + */ + allow_rebase_update?: boolean; + /** + * either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. + */ + allow_squash_merge?: boolean; + /** + * set to `true` to archive this repository. + */ + archived?: boolean; + /** + * either `true` to enable AutodetectManualMerge, or `false` to prevent it. Note: In some special cases, misjudgments can occur. + */ + autodetect_manual_merge?: boolean; + /** + * set to `true` to allow edits from maintainers by default + */ + default_allow_maintainer_edit?: boolean; + /** + * sets the default branch for this repository. + */ + default_branch?: string; + /** + * set to `true` to delete pr branch after merge by default + */ + default_delete_branch_after_merge?: boolean; + /** + * set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", or "squash". + */ + default_merge_style?: string; + /** + * a short description of the repository. + */ + description?: string; + /** + * enable prune - remove obsolete remote-tracking references + */ + enable_prune?: boolean; + external_tracker?: ExternalTracker; + external_wiki?: ExternalWiki; + /** + * either `true` to enable issues for this repository or `false` to disable them. + */ + has_issues?: boolean; + /** + * either `true` to enable project unit, or `false` to disable them. + */ + has_projects?: boolean; + /** + * either `true` to allow pull requests, or `false` to prevent pull request. + */ + has_pull_requests?: boolean; + /** + * either `true` to enable the wiki for this repository or `false` to disable it. + */ + has_wiki?: boolean; + /** + * either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. + */ + ignore_whitespace_conflicts?: boolean; + internal_tracker?: InternalTracker; + /** + * set to a string like `8h30m0s` to set the mirror interval time + */ + mirror_interval?: string; + /** + * name of the repository + */ + name?: string; + /** + * either `true` to make the repository private or `false` to make it public. + * Note: you will get a 422 error if the organization restricts changing repository visibility to organization + * owners and a non-owner tries to change the value of private. + */ + private?: boolean; + /** + * either `true` to make this repository a template or `false` to make it a normal repository + */ + template?: boolean; + /** + * a URL with more information about the repository. + */ + website?: string; +} +/** + * EditTeamOption options for editing a team + */ +export interface EditTeamOption { + can_create_org_repo?: boolean; + description?: string; + includes_all_repositories?: boolean; + name: string; + permission?: "read" | "write" | "admin"; + /** + * example: + * repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.projects,repo.ext_wiki + */ + units?: string[]; + /** + * example: + * [object Object] + */ + units_map?: { + [name: string]: string; + }; +} +/** + * EditUserOption edit user options + */ +export interface EditUserOption { + active?: boolean; + admin?: boolean; + allow_create_organization?: boolean; + allow_git_hook?: boolean; + allow_import_local?: boolean; + description?: string; + email?: string; // email + full_name?: string; + location?: string; + login_name: string; + max_repo_creation?: number; // int64 + must_change_password?: boolean; + password?: string; + prohibit_login?: boolean; + restricted?: boolean; + source_id: number; // int64 + visibility?: string; + website?: string; +} +/** + * Email an email address belonging to a user + */ +export interface Email { + email?: string; // email + primary?: boolean; + verified?: boolean; +} +/** + * ExternalTracker represents settings for external tracker + */ +export interface ExternalTracker { + /** + * External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index. + */ + external_tracker_format?: string; + /** + * External Issue Tracker issue regular expression + */ + external_tracker_regexp_pattern?: string; + /** + * External Issue Tracker Number Format, either `numeric`, `alphanumeric`, or `regexp` + */ + external_tracker_style?: string; + /** + * URL of external issue tracker. + */ + external_tracker_url?: string; +} +/** + * ExternalWiki represents setting for external wiki + */ +export interface ExternalWiki { + /** + * URL of external wiki. + */ + external_wiki_url?: string; +} +/** + * FileCommitResponse contains information generated from a Git commit for a repo's file. + */ +export interface FileCommitResponse { + author?: CommitUser; + committer?: CommitUser; + created?: string; // date-time + html_url?: string; + message?: string; + parents?: CommitMeta[]; + sha?: string; + tree?: CommitMeta; + url?: string; +} +/** + * FileDeleteResponse contains information about a repo's file that was deleted + */ +export interface FileDeleteResponse { + commit?: FileCommitResponse; + content?: any; + verification?: PayloadCommitVerification; +} +/** + * FileLinksResponse contains the links for a repo's file + */ +export interface FileLinksResponse { + git?: string; + html?: string; + self?: string; +} +/** + * FileResponse contains information about a repo's file + */ +export interface FileResponse { + commit?: FileCommitResponse; + content?: ContentsResponse; + verification?: PayloadCommitVerification; +} +/** + * GPGKey a user GPG key to sign commit and tag in repository + */ +export interface GPGKey { + can_certify?: boolean; + can_encrypt_comms?: boolean; + can_encrypt_storage?: boolean; + can_sign?: boolean; + created_at?: string; // date-time + emails?: GPGKeyEmail[]; + expires_at?: string; // date-time + id?: number; // int64 + key_id?: string; + primary_key_id?: string; + public_key?: string; + subkeys?: GPGKey[]; + verified?: boolean; +} +/** + * GPGKeyEmail an email attached to a GPGKey + */ +export interface GPGKeyEmail { + email?: string; + verified?: boolean; +} +/** + * GeneralAPISettings contains global api settings exposed by it + */ +export interface GeneralAPISettings { + default_git_trees_per_page?: number; // int64 + default_max_blob_size?: number; // int64 + default_paging_num?: number; // int64 + max_response_items?: number; // int64 +} +/** + * GeneralAttachmentSettings contains global Attachment settings exposed by API + */ +export interface GeneralAttachmentSettings { + allowed_types?: string; + enabled?: boolean; + max_files?: number; // int64 + max_size?: number; // int64 +} +/** + * GeneralRepoSettings contains global repository settings exposed by API + */ +export interface GeneralRepoSettings { + http_git_disabled?: boolean; + lfs_disabled?: boolean; + migrations_disabled?: boolean; + mirrors_disabled?: boolean; + stars_disabled?: boolean; + time_tracking_disabled?: boolean; +} +/** + * GeneralUISettings contains global ui settings exposed by API + */ +export interface GeneralUISettings { + allowed_reactions?: string[]; + custom_emojis?: string[]; + default_theme?: string; +} +/** + * GenerateRepoOption options when creating repository using a template + */ +export interface GenerateRepoOption { + /** + * include avatar of the template repo + */ + avatar?: boolean; + /** + * Default branch of the new repository + */ + default_branch?: string; + /** + * Description of the repository to create + */ + description?: string; + /** + * include git content of default branch in template repo + */ + git_content?: boolean; + /** + * include git hooks in template repo + */ + git_hooks?: boolean; + /** + * include labels in template repo + */ + labels?: boolean; + /** + * Name of the repository to create + */ + name: string; + /** + * The organization or person who will own the new repository + */ + owner: string; + /** + * Whether the repository is private + */ + private?: boolean; + /** + * include topics in template repo + */ + topics?: boolean; + /** + * include webhooks in template repo + */ + webhooks?: boolean; +} +/** + * GitBlobResponse represents a git blob + */ +export interface GitBlobResponse { + content?: string; + encoding?: string; + sha?: string; + size?: number; // int64 + url?: string; +} +/** + * GitEntry represents a git tree + */ +export interface GitEntry { + mode?: string; + path?: string; + sha?: string; + size?: number; // int64 + type?: string; + url?: string; +} +/** + * GitHook represents a Git repository hook + */ +export interface GitHook { + content?: string; + is_active?: boolean; + name?: string; +} +/** + * GitObject represents a Git object. + */ +export interface GitObject { + sha?: string; + type?: string; + url?: string; +} +/** + * GitTreeResponse returns a git tree + */ +export interface GitTreeResponse { + page?: number; // int64 + sha?: string; + total_count?: number; // int64 + tree?: GitEntry[]; + truncated?: boolean; + url?: string; +} +/** + * Hook a hook is a web hook when one repository changed + */ +export interface Hook { + active?: boolean; + authorization_header?: string; + config?: { + [name: string]: string; + }; + created_at?: string; // date-time + events?: string[]; + id?: number; // int64 + type?: string; + updated_at?: string; // date-time +} +/** + * Identity for a person's identity like an author or committer + */ +export interface Identity { + email?: string; // email + name?: string; +} +/** + * InternalTracker represents settings for internal tracker + */ +export interface InternalTracker { + /** + * Let only contributors track time (Built-in issue tracker) + */ + allow_only_contributors_to_track_time?: boolean; + /** + * Enable dependencies for issues and pull requests (Built-in issue tracker) + */ + enable_issue_dependencies?: boolean; + /** + * Enable time tracking (Built-in issue tracker) + */ + enable_time_tracker?: boolean; +} +/** + * Issue represents an issue in a repository + */ +export interface Issue { + assets?: Attachment[]; + assignee?: User; + assignees?: User[]; + body?: string; + closed_at?: string; // date-time + comments?: number; // int64 + created_at?: string; // date-time + due_date?: string; // date-time + html_url?: string; + id?: number; // int64 + is_locked?: boolean; + labels?: Label[]; + milestone?: Milestone; + number?: number; // int64 + original_author?: string; + original_author_id?: number; // int64 + pull_request?: PullRequestMeta; + ref?: string; + repository?: RepositoryMeta; + state?: StateType; + title?: string; + updated_at?: string; // date-time + url?: string; + user?: User; +} +/** + * IssueDeadline represents an issue deadline + */ +export interface IssueDeadline { + due_date?: string; // date-time +} +/** + * IssueFormField represents a form field + */ +export interface IssueFormField { + attributes?: { + [name: string]: any; + }; + id?: string; + type?: IssueFormFieldType; + validations?: { + [name: string]: any; + }; +} +/** + * IssueFormFieldType defines issue form field type, can be "markdown", "textarea", "input", "dropdown" or "checkboxes" + */ +export type IssueFormFieldType = string; +/** + * IssueLabelsOption a collection of labels + */ +export interface IssueLabelsOption { + /** + * list of label IDs + */ + labels?: number /* int64 */ []; +} +/** + * IssueTemplate represents an issue template for a repository + */ +export interface IssueTemplate { + about?: string; + body?: IssueFormField[]; + content?: string; + file_name?: string; + labels?: IssueTemplateLabels; + name?: string; + ref?: string; + title?: string; +} +export type IssueTemplateLabels = string[]; +/** + * Label a label to an issue or a pr + */ +export interface Label { + /** + * example: + * 00aabb + */ + color?: string; + description?: string; + /** + * example: + * false + */ + exclusive?: boolean; + id?: number; // int64 + name?: string; + url?: string; +} +/** + * MarkdownOption markdown options + */ +export interface MarkdownOption { + /** + * Context to render + * + * in: body + */ + Context?: string; + /** + * Mode to render + * + * in: body + */ + Mode?: string; + /** + * Text markdown to render + * + * in: body + */ + Text?: string; + /** + * Is it a wiki page ? + * + * in: body + */ + Wiki?: boolean; +} +/** + * MergePullRequestForm form for merging Pull Request + */ +export interface MergePullRequestOption { + Do: "merge" | "rebase" | "rebase-merge" | "squash" | "manually-merged"; + MergeCommitID?: string; + MergeMessageField?: string; + MergeTitleField?: string; + delete_branch_after_merge?: boolean; + force_merge?: boolean; + head_commit_id?: string; + merge_when_checks_succeed?: boolean; +} +/** + * MigrateRepoOptions options for migrating repository's + * this is used to interact with api v1 + */ +export interface MigrateRepoOptions { + auth_password?: string; + auth_token?: string; + auth_username?: string; + clone_addr: string; + description?: string; + issues?: boolean; + labels?: boolean; + lfs?: boolean; + lfs_endpoint?: string; + milestones?: boolean; + mirror?: boolean; + mirror_interval?: string; + private?: boolean; + pull_requests?: boolean; + releases?: boolean; + repo_name: string; + /** + * Name of User or Organisation who will own Repo after migration + */ + repo_owner?: string; + service?: "git" | "github" | "gitea" | "gitlab"; + /** + * deprecated (only for backwards compatibility) + */ + uid?: number; // int64 + wiki?: boolean; +} +/** + * Milestone milestone is a collection of issues on one repository + */ +export interface Milestone { + closed_at?: string; // date-time + closed_issues?: number; // int64 + created_at?: string; // date-time + description?: string; + due_on?: string; // date-time + id?: number; // int64 + open_issues?: number; // int64 + state?: StateType; + title?: string; + updated_at?: string; // date-time +} +/** + * NodeInfo contains standardized way of exposing metadata about a server running one of the distributed social networks + */ +export interface NodeInfo { + metadata?: { + }; + openRegistrations?: boolean; + protocols?: string[]; + services?: NodeInfoServices; + software?: NodeInfoSoftware; + usage?: NodeInfoUsage; + version?: string; +} +/** + * NodeInfoServices contains the third party sites this server can connect to via their application API + */ +export interface NodeInfoServices { + inbound?: string[]; + outbound?: string[]; +} +/** + * NodeInfoSoftware contains Metadata about server software in use + */ +export interface NodeInfoSoftware { + homepage?: string; + name?: string; + repository?: string; + version?: string; +} +/** + * NodeInfoUsage contains usage statistics for this server + */ +export interface NodeInfoUsage { + localComments?: number; // int64 + localPosts?: number; // int64 + users?: NodeInfoUsageUsers; +} +/** + * NodeInfoUsageUsers contains statistics about the users of this server + */ +export interface NodeInfoUsageUsers { + activeHalfyear?: number; // int64 + activeMonth?: number; // int64 + total?: number; // int64 +} +/** + * Note contains information related to a git note + */ +export interface Note { + commit?: Commit; + message?: string; +} +/** + * NotificationCount number of unread notifications + */ +export interface NotificationCount { + new?: number; // int64 +} +/** + * NotificationSubject contains the notification subject (Issue/Pull/Commit) + */ +export interface NotificationSubject { + html_url?: string; + latest_comment_html_url?: string; + latest_comment_url?: string; + state?: StateType; + title?: string; + type?: NotifySubjectType; + url?: string; +} +/** + * NotificationThread expose Notification on API + */ +export interface NotificationThread { + id?: number; // int64 + pinned?: boolean; + repository?: Repository; + subject?: NotificationSubject; + unread?: boolean; + updated_at?: string; // date-time + url?: string; +} +/** + * NotifySubjectType represent type of notification subject + */ +export type NotifySubjectType = string; +/** + * OAuth2Application represents an OAuth2 application. + */ +export interface OAuth2Application { + client_id?: string; + client_secret?: string; + confidential_client?: boolean; + created?: string; // date-time + id?: number; // int64 + name?: string; + redirect_uris?: string[]; +} +/** + * Organization represents an organization + */ +export interface Organization { + avatar_url?: string; + description?: string; + full_name?: string; + id?: number; // int64 + location?: string; + name?: string; + repo_admin_change_team_access?: boolean; + /** + * deprecated + */ + username?: string; + visibility?: string; + website?: string; +} +/** + * OrganizationPermissions list different users permissions on an organization + */ +export interface OrganizationPermissions { + can_create_repository?: boolean; + can_read?: boolean; + can_write?: boolean; + is_admin?: boolean; + is_owner?: boolean; +} +/** + * PRBranchInfo information about a branch + */ +export interface PRBranchInfo { + label?: string; + ref?: string; + repo?: Repository; + repo_id?: number; // int64 + sha?: string; +} +/** + * Package represents a package + */ +export interface Package { + created_at?: string; // date-time + creator?: User; + id?: number; // int64 + name?: string; + owner?: User; + repository?: Repository; + type?: string; + version?: string; +} +/** + * PackageFile represents a package file + */ +export interface PackageFile { + Size?: number; // int64 + id?: number; // int64 + md5?: string; + name?: string; + sha1?: string; + sha256?: string; + sha512?: string; +} +/** + * PayloadCommit represents a commit + */ +export interface PayloadCommit { + added?: string[]; + author?: PayloadUser; + committer?: PayloadUser; + /** + * sha1 hash of the commit + */ + id?: string; + message?: string; + modified?: string[]; + removed?: string[]; + timestamp?: string; // date-time + url?: string; + verification?: PayloadCommitVerification; +} +/** + * PayloadCommitVerification represents the GPG verification of a commit + */ +export interface PayloadCommitVerification { + payload?: string; + reason?: string; + signature?: string; + signer?: PayloadUser; + verified?: boolean; +} +/** + * PayloadUser represents the author or committer of a commit + */ +export interface PayloadUser { + email?: string; // email + /** + * Full name of the commit author + */ + name?: string; + username?: string; +} +/** + * Permission represents a set of permissions + */ +export interface Permission { + admin?: boolean; + pull?: boolean; + push?: boolean; +} +/** + * PublicKey publickey is a user key to push code to repository + */ +export interface PublicKey { + created_at?: string; // date-time + fingerprint?: string; + id?: number; // int64 + key?: string; + key_type?: string; + read_only?: boolean; + title?: string; + url?: string; + user?: User; +} +/** + * PullRequest represents a pull request + */ +export interface PullRequest { + allow_maintainer_edit?: boolean; + assignee?: User; + assignees?: User[]; + base?: PRBranchInfo; + body?: string; + closed_at?: string; // date-time + comments?: number; // int64 + created_at?: string; // date-time + diff_url?: string; + due_date?: string; // date-time + head?: PRBranchInfo; + html_url?: string; + id?: number; // int64 + is_locked?: boolean; + labels?: Label[]; + merge_base?: string; + merge_commit_sha?: string; + mergeable?: boolean; + merged?: boolean; + merged_at?: string; // date-time + merged_by?: User; + milestone?: Milestone; + number?: number; // int64 + patch_url?: string; + state?: StateType; + title?: string; + updated_at?: string; // date-time + url?: string; + user?: User; +} +/** + * PullRequestMeta PR info if an issue is a PR + */ +export interface PullRequestMeta { + merged?: boolean; + merged_at?: string; // date-time +} +/** + * PullReview represents a pull request review + */ +export interface PullReview { + body?: string; + comments_count?: number; // int64 + commit_id?: string; + dismissed?: boolean; + html_url?: string; + id?: number; // int64 + official?: boolean; + pull_request_url?: string; + stale?: boolean; + state?: ReviewStateType; + submitted_at?: string; // date-time + team?: Team; + updated_at?: string; // date-time + user?: User; +} +/** + * PullReviewComment represents a comment on a pull request review + */ +export interface PullReviewComment { + body?: string; + commit_id?: string; + created_at?: string; // date-time + diff_hunk?: string; + html_url?: string; + id?: number; // int64 + original_commit_id?: string; + original_position?: number; // uint64 + path?: string; + position?: number; // uint64 + pull_request_review_id?: number; // int64 + pull_request_url?: string; + resolver?: User; + updated_at?: string; // date-time + user?: User; +} +/** + * PullReviewRequestOptions are options to add or remove pull review requests + */ +export interface PullReviewRequestOptions { + reviewers?: string[]; + team_reviewers?: string[]; +} +/** + * PushMirror represents information of a push mirror + */ +export interface PushMirror { + created?: string; + interval?: string; + last_error?: string; + last_update?: string; + remote_address?: string; + remote_name?: string; + repo_name?: string; + sync_on_commit?: boolean; +} +/** + * Reaction contain one reaction + */ +export interface Reaction { + content?: string; + created_at?: string; // date-time + user?: User; +} +/** + * Reference represents a Git reference. + */ +export interface Reference { + object?: GitObject; + ref?: string; + url?: string; +} +/** + * Release represents a repository release + */ +export interface Release { + assets?: Attachment[]; + author?: User; + body?: string; + created_at?: string; // date-time + draft?: boolean; + html_url?: string; + id?: number; // int64 + name?: string; + prerelease?: boolean; + published_at?: string; // date-time + tag_name?: string; + tarball_url?: string; + target_commitish?: string; + url?: string; + zipball_url?: string; +} +/** + * RepoCollaboratorPermission to get repository permission for a collaborator + */ +export interface RepoCollaboratorPermission { + permission?: string; + role_name?: string; + user?: User; +} +/** + * RepoCommit contains information of a commit in the context of a repository. + */ +export interface RepoCommit { + author?: CommitUser; + committer?: CommitUser; + message?: string; + tree?: CommitMeta; + url?: string; + verification?: PayloadCommitVerification; +} +/** + * RepoTopicOptions a collection of repo topic names + */ +export interface RepoTopicOptions { + /** + * list of topic names + */ + topics?: string[]; +} +/** + * RepoTransfer represents a pending repo transfer + */ +export interface RepoTransfer { + doer?: User; + recipient?: User; + teams?: Team[]; +} +/** + * Repository represents a repository + */ +export interface Repository { + allow_merge_commits?: boolean; + allow_rebase?: boolean; + allow_rebase_explicit?: boolean; + allow_rebase_update?: boolean; + allow_squash_merge?: boolean; + archived?: boolean; + avatar_url?: string; + clone_url?: string; + created_at?: string; // date-time + default_allow_maintainer_edit?: boolean; + default_branch?: string; + default_delete_branch_after_merge?: boolean; + default_merge_style?: string; + description?: string; + empty?: boolean; + external_tracker?: ExternalTracker; + external_wiki?: ExternalWiki; + fork?: boolean; + forks_count?: number; // int64 + full_name?: string; + has_issues?: boolean; + has_projects?: boolean; + has_pull_requests?: boolean; + has_wiki?: boolean; + html_url?: string; + id?: number; // int64 + ignore_whitespace_conflicts?: boolean; + internal?: boolean; + internal_tracker?: InternalTracker; + language?: string; + languages_url?: string; + link?: string; + mirror?: boolean; + mirror_interval?: string; + mirror_updated?: string; // date-time + name?: string; + open_issues_count?: number; // int64 + open_pr_counter?: number; // int64 + original_url?: string; + owner?: User; + parent?: Repository; + permissions?: Permission; + private?: boolean; + release_counter?: number; // int64 + repo_transfer?: RepoTransfer; + size?: number; // int64 + ssh_url?: string; + stars_count?: number; // int64 + template?: boolean; + updated_at?: string; // date-time + watchers_count?: number; // int64 + website?: string; +} +/** + * RepositoryMeta basic repository information + */ +export interface RepositoryMeta { + full_name?: string; + id?: number; // int64 + name?: string; + owner?: string; +} +/** + * ReviewStateType review state type + */ +export type ReviewStateType = string; +/** + * SearchResults results of a successful search + */ +export interface SearchResults { + data?: Repository[]; + ok?: boolean; +} +/** + * ServerVersion wraps the version of the server + */ +export interface ServerVersion { + version?: string; +} +/** + * StateType issue state type + */ +export type StateType = string; +/** + * StopWatch represent a running stopwatch + */ +export interface StopWatch { + created?: string; // date-time + duration?: string; + issue_index?: number; // int64 + issue_title?: string; + repo_name?: string; + repo_owner_name?: string; + seconds?: number; // int64 +} +/** + * SubmitPullReviewOptions are options to submit a pending pull review + */ +export interface SubmitPullReviewOptions { + body?: string; + event?: ReviewStateType; +} +/** + * Tag represents a repository tag + */ +export interface Tag { + commit?: CommitMeta; + id?: string; + message?: string; + name?: string; + tarball_url?: string; + zipball_url?: string; +} +/** + * Team represents a team in an organization + */ +export interface Team { + can_create_org_repo?: boolean; + description?: string; + id?: number; // int64 + includes_all_repositories?: boolean; + name?: string; + organization?: Organization; + permission?: "none" | "read" | "write" | "admin" | "owner"; + /** + * example: + * repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.projects,repo.ext_wiki + */ + units?: string[]; + /** + * example: + * [object Object] + */ + units_map?: { + [name: string]: string; + }; +} +/** + * TimeStamp defines a timestamp + */ +export type TimeStamp = number; // int64 +/** + * TimelineComment represents a timeline comment (comment of any type) on a commit or issue + */ +export interface TimelineComment { + assignee?: User; + assignee_team?: Team; + body?: string; + created_at?: string; // date-time + dependent_issue?: Issue; + html_url?: string; + id?: number; // int64 + issue_url?: string; + label?: Label; + milestone?: Milestone; + new_ref?: string; + new_title?: string; + old_milestone?: Milestone; + old_project_id?: number; // int64 + old_ref?: string; + old_title?: string; + project_id?: number; // int64 + pull_request_url?: string; + ref_action?: string; + ref_comment?: Comment; + /** + * commit SHA where issue/PR was referenced + */ + ref_commit_sha?: string; + ref_issue?: Issue; + /** + * whether the assignees were removed or added + */ + removed_assignee?: boolean; + resolve_doer?: User; + review_id?: number; // int64 + tracked_time?: TrackedTime; + type?: string; + updated_at?: string; // date-time + user?: User; +} +/** + * TopicName a list of repo topic names + */ +export interface TopicName { + topics?: string[]; +} +/** + * TopicResponse for returning topics + */ +export interface TopicResponse { + created?: string; // date-time + id?: number; // int64 + repo_count?: number; // int64 + topic_name?: string; + updated?: string; // date-time +} +/** + * TrackedTime worked time for an issue / pr + */ +export interface TrackedTime { + created?: string; // date-time + id?: number; // int64 + issue?: Issue; + /** + * deprecated (only for backwards compatibility) + */ + issue_id?: number; // int64 + /** + * Time in seconds + */ + time?: number; // int64 + /** + * deprecated (only for backwards compatibility) + */ + user_id?: number; // int64 + user_name?: string; +} +/** + * TransferRepoOption options when transfer a repository's ownership + */ +export interface TransferRepoOption { + new_owner: string; + /** + * ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories. + */ + team_ids?: number /* int64 */ []; +} +/** + * UpdateFileOptions options for updating files + * Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) + */ +export interface UpdateFileOptions { + author?: Identity; + /** + * branch (optional) to base this file from. if not given, the default branch is used + */ + branch?: string; + committer?: Identity; + /** + * content must be base64 encoded + */ + content: string; + dates?: CommitDateOptions; + /** + * from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL + */ + from_path?: string; + /** + * message (optional) for the commit of this file. if not supplied, a default message will be used + */ + message?: string; + /** + * new_branch (optional) will make a new branch from `branch` before creating the file + */ + new_branch?: string; + /** + * sha is the SHA for the file that already exists + */ + sha: string; + /** + * Add a Signed-off-by trailer by the committer at the end of the commit log message. + */ + signoff?: boolean; +} +/** + * User represents a user + */ +export interface User { + /** + * Is user active + */ + active?: boolean; + /** + * URL to the user's avatar + */ + avatar_url?: string; + created?: string; // date-time + /** + * the user's description + */ + description?: string; + email?: string; // email + /** + * user counts + */ + followers_count?: number; // int64 + following_count?: number; // int64 + /** + * the user's full name + */ + full_name?: string; + /** + * the user's id + */ + id?: number; // int64 + /** + * Is the user an administrator + */ + is_admin?: boolean; + /** + * User locale + */ + language?: string; + last_login?: string; // date-time + /** + * the user's location + */ + location?: string; + /** + * the user's username + */ + login?: string; + /** + * the user's authentication sign-in name. + */ + login_name?: string; + /** + * Is user login prohibited + */ + prohibit_login?: boolean; + /** + * Is user restricted + */ + restricted?: boolean; + starred_repos_count?: number; // int64 + /** + * User visibility level option: public, limited, private + */ + visibility?: string; + /** + * the user's website + */ + website?: string; +} +/** + * UserHeatmapData represents the data needed to create a heatmap + */ +export interface UserHeatmapData { + contributions?: number; // int64 + timestamp?: TimeStamp; // int64 +} +/** + * UserSettings represents user settings + */ +export interface UserSettings { + description?: string; + diff_view_style?: string; + full_name?: string; + hide_activity?: boolean; + /** + * Privacy + */ + hide_email?: boolean; + language?: string; + location?: string; + theme?: string; + website?: string; +} +/** + * UserSettingsOptions represents options to change user settings + */ +export interface UserSettingsOptions { + description?: string; + diff_view_style?: string; + full_name?: string; + hide_activity?: boolean; + /** + * Privacy + */ + hide_email?: boolean; + language?: string; + location?: string; + theme?: string; + website?: string; +} +/** + * WatchInfo represents an API watch status of one repository + */ +export interface WatchInfo { + created_at?: string; // date-time + ignored?: boolean; + reason?: any; + repository_url?: string; + subscribed?: boolean; + url?: string; +} +/** + * WikiCommit page commit/revision + */ +export interface WikiCommit { + author?: CommitUser; + commiter?: CommitUser; + message?: string; + sha?: string; +} +/** + * WikiCommitList commit/revision list + */ +export interface WikiCommitList { + commits?: WikiCommit[]; + count?: number; // int64 +} +/** + * WikiPage a wiki page + */ +export interface WikiPage { + commit_count?: number; // int64 + /** + * Page content, base64 encoded + */ + content_base64?: string; + footer?: string; + html_url?: string; + last_commit?: WikiCommit; + sidebar?: string; + sub_url?: string; + title?: string; +} +/** + * WikiPageMetaData wiki page meta information + */ +export interface WikiPageMetaData { + html_url?: string; + last_commit?: WikiCommit; + sub_url?: string; + title?: string; +}