From 8d9d3b2a8fdcefd9f7f4e157386b8990e9610d11 Mon Sep 17 00:00:00 2001 From: Abhas Date: Tue, 10 Jul 2018 14:30:05 +0530 Subject: [PATCH] Reformat types file --- src/types/index.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/types/index.ts b/src/types/index.ts index 85591ea..1e5f073 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -8,15 +8,18 @@ interface RequestOptions { query?: string; variables?: Variables; } + interface Result { headers: { status: string; }; } + interface OctokitError { code: number; status: string; } + export interface OctokitMod extends Octokit { // The following are added because Octokit does not expose the hook.error, hook.before, and hook.after methods hook: { @@ -25,29 +28,37 @@ export interface OctokitMod extends Octokit { after: (when: 'request', callback: (result: Result, options: RequestOptions) => void) => void; }; } + interface Variables { [key: string]: any; } + export interface ResponseWithDataArray { data: T[]; } + interface ResponseWithMetaLink { meta: { link: string; }; } + export interface ResponseWithDataArrayAndMeta extends ResponseWithDataArray, ResponseWithMetaLink { } + export interface ResponseFromGetUserRepo extends ResponseWithMetaLink { data: RepoFromGetUserRepo[]; } + export interface ResponseFromGetBranches extends ResponseWithMetaLink { data: BranchFromGetBranches[]; } + export interface ResponseFromGetRepo { data: RepoFromGetRepo; meta: {}; } + export interface ResponseFromCompareCommits { data: { status: string; @@ -56,9 +67,11 @@ export interface ResponseFromCompareCommits { total_commits: number; }; } + export interface ResponseFromGetContributors extends ResponseWithMetaLink { data: OwnerFromGetContributors[] | undefined; } + export interface RepoFromGetUserRepo { default_branch: string; description: string; @@ -73,6 +86,7 @@ export interface RepoFromGetUserRepo { pushed_at: string; url: string; } + interface OwnerFromGetUserRepo { avatar_url: string; gravatar_id: string; @@ -82,35 +96,45 @@ interface OwnerFromGetUserRepo { repos_url: string; type: UserType; } + export type OwnerFromGetContributors = OwnerFromGetUserRepo; + enum UserType { User = 'User' } + export interface BranchFromGetBranches { name: string; commit: CommitFromGetBranches; } + interface CommitFromGetBranches { sha: string; url: string; } + interface RepoFromGetRepo { parent: RepoFromGetUserRepo; } + export interface RepoNameWithUnusedFlag { repoName: string; unused: boolean; } + export interface RepoNameWithBranches { repoName: string; branches: BranchFromGetBranches[]; } + export interface RepoNameWithParentRepo { repoName: string; parentRepo: RepoFromGetUserRepo; } + export interface RepoNameWithBranchesAndParent extends RepoNameWithBranches, RepoNameWithParentRepo { } + export interface ObjectWithPerPage { per_page?: number; }