Skip to content

Commit ce91928

Browse files
committed
adds basic typings
1 parent 9cbe83e commit ce91928

File tree

2 files changed

+220
-0
lines changed

2 files changed

+220
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.2.1",
44
"description": "React hooks for Github API",
55
"main": "src/index.js",
6+
"types": "types.d.ts",
67
"repository": "https://github.com/bdbch/react-github",
78
"author": "@d2k",
89
"license": "MIT",

types.d.ts

+219
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
interface IGithubRepoPermissions {
2+
admin: boolean;
3+
push: boolean;
4+
pull: boolean;
5+
}
6+
7+
interface IGithubLicense {
8+
key: string;
9+
name: string;
10+
spdx_id: string;
11+
url: string;
12+
node_id: string;
13+
}
14+
15+
interface IGithubOrganization {
16+
login: string;
17+
id: number;
18+
node_id: string;
19+
avatar_url: string;
20+
gravatar_id: string;
21+
url: string;
22+
html_url: string;
23+
followers_url: string;
24+
following_url: string;
25+
gists_url: string;
26+
starred_url: string;
27+
subscriptions_url: string;
28+
organizations_url: string;
29+
repos_url: string;
30+
events_url: string;
31+
received_events_url: string;
32+
type: string;
33+
site_admin: boolean;
34+
}
35+
36+
interface IGithubBaseUser {
37+
login: string;
38+
id: number;
39+
node_id: string;
40+
avatar_url: string;
41+
gravatar_id: string;
42+
url: string;
43+
html_url: string;
44+
followers_url: string;
45+
following_url: string;
46+
gists_url: string;
47+
starred_url: string;
48+
subscriptions_url: string;
49+
organizations_url: string;
50+
repos_url: string;
51+
events_url: string;
52+
received_events_url: string;
53+
type: "User";
54+
site_admin: boolean;
55+
}
56+
57+
interface IGithubUser extends IGithubBaseUser {
58+
name: string;
59+
company: string;
60+
blog: string;
61+
location: string;
62+
email: string;
63+
hireable: boolean;
64+
bio: string;
65+
public_repos: number;
66+
public_gists: number;
67+
followers: number;
68+
following: number;
69+
created_at: string;
70+
updated_at: string;
71+
}
72+
73+
interface IGithubRepo {
74+
id: number;
75+
node_id: string;
76+
name: string;
77+
full_name: string;
78+
owner: IGithubBaseUser;
79+
private: boolean;
80+
html_url: string;
81+
description: string;
82+
fork: boolean;
83+
url: string;
84+
archive_url: string;
85+
assignees_url: string;
86+
blobs_url: string;
87+
branches_url: string;
88+
collaborators_url: string;
89+
comments_url: string;
90+
commits_url: string;
91+
compare_url: string;
92+
contents_url: string;
93+
contributors_url: string;
94+
deployments_url: string;
95+
downloads_url: string;
96+
events_url: string;
97+
forks_url: string;
98+
git_commits_url: string;
99+
git_refs_url: string;
100+
git_tags_url: string;
101+
git_url: string;
102+
issue_comment_url: string;
103+
issue_events_url: string;
104+
issues_url: string;
105+
keys_url: string;
106+
labels_url: string;
107+
languages_url: string;
108+
merges_url: string;
109+
milestones_url: string;
110+
notifications_url: string;
111+
pulls_url: string;
112+
releases_url: string;
113+
ssh_url: string;
114+
stargazers_url: string;
115+
statuses_url: string;
116+
subscribers_url: string;
117+
subscription_url: string;
118+
tags_url: string;
119+
teams_url: string;
120+
trees_url: string;
121+
clone_url: string;
122+
mirror_url: string;
123+
hooks_url: string;
124+
svn_url: string;
125+
homepage: string;
126+
language?: string;
127+
forks_count: number;
128+
stargazers_count: number;
129+
watchers_count: number;
130+
size: number;
131+
default_branch: string;
132+
open_issues_count: number;
133+
is_template: boolean;
134+
topics: string[];
135+
has_issues: boolean;
136+
has_projects: boolean;
137+
has_wiki: boolean;
138+
has_pages: boolean;
139+
has_downloads: boolean;
140+
archived: boolean;
141+
disabled: boolean;
142+
pushed_at: string;
143+
created_at: string;
144+
updated_at: string;
145+
permissions: IGithubRepoPermissions;
146+
allow_rebase_merge: boolean;
147+
template_repository?: string;
148+
allow_squash_merge: boolean;
149+
allow_merge_commit: boolean;
150+
subscribers_count: number;
151+
network_count: number;
152+
license: IGithubLicense;
153+
organization?: IGithubOrganization;
154+
parent?: IGithubRepo;
155+
}
156+
157+
interface IUserResponse {
158+
user?: IGithubUser;
159+
loading: boolean;
160+
error?: string;
161+
}
162+
163+
interface IReposResponse {
164+
repos?: IGithubRepo[];
165+
loading: boolean;
166+
error?: string;
167+
}
168+
169+
interface IBranchResponse {
170+
branch?: any;
171+
loading: boolean;
172+
error?: string;
173+
}
174+
175+
interface IBranchesResponse {
176+
branches?: any[];
177+
loading: boolean;
178+
error?: string;
179+
}
180+
181+
interface IReleaseResponse {
182+
release?: any;
183+
loading: boolean;
184+
error?: string;
185+
}
186+
187+
interface ICollaboratorsResponse {
188+
collaborators?: any[];
189+
loading: boolean;
190+
error?: string;
191+
}
192+
193+
interface IForksResponse {
194+
forks?: any[];
195+
loading: boolean;
196+
error?: string;
197+
}
198+
199+
declare function useUser(githubUserName: string): IUserResponse;
200+
declare function useRepos(githubUserName: string): IReposResponse;
201+
declare function useBranch(
202+
owner: string,
203+
repo: string,
204+
branch: string
205+
): IBranchResponse;
206+
declare function useBranches(owner: string, repo: string): IBranchesResponse;
207+
declare function useLatestRelease(
208+
owner: string,
209+
repo: string
210+
): IReleaseResponse;
211+
declare function useTaggedRelease(
212+
owner: string,
213+
repo: string
214+
): IReleaseResponse;
215+
declare function useCollaborators(
216+
owner: string,
217+
repo: string
218+
): ICollaboratorsResponse;
219+
declare function useForks(owner: string, repo: string): IForksResponse;

0 commit comments

Comments
 (0)