@tomsd/github-repo-js 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14047 -504
- package/dist/index.iife.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/modules/github-classes.d.ts +17050 -642
- package/dist/modules/issue-comments.d.ts +470 -20
- package/dist/modules/issue.d.ts +2078 -83
- package/dist/modules/my-issues.d.ts +1890 -75
- package/dist/modules/organization-repositories.d.ts +270 -15
- package/dist/modules/pull-commits.d.ts +390 -30
- package/dist/modules/pull-reviewers.d.ts +330 -10
- package/dist/modules/repository-branch.d.ts +2620 -10
- package/dist/modules/repository-branches.d.ts +2100 -5
- package/dist/modules/repository-issues.d.ts +1894 -79
- package/dist/modules/repository-pull.d.ts +2985 -115
- package/dist/modules/repository-pulls.d.ts +2775 -100
- package/dist/modules/repository-releases.d.ts +375 -15
- package/dist/modules/repository-runs.d.ts +2000 -35
- package/dist/modules/repository.d.ts +12840 -467
- package/dist/modules/user-repositories.d.ts +160 -10
- package/dist/repl.mjs +1 -1
- package/package.json +5 -3
|
@@ -7,7 +7,14 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
7
7
|
node_id: string;
|
|
8
8
|
name: string;
|
|
9
9
|
full_name: string;
|
|
10
|
-
license:
|
|
10
|
+
license: {
|
|
11
|
+
key: string;
|
|
12
|
+
name: string;
|
|
13
|
+
url: string | null;
|
|
14
|
+
spdx_id: string | null;
|
|
15
|
+
node_id: string;
|
|
16
|
+
html_url?: string;
|
|
17
|
+
} | null;
|
|
11
18
|
forks: number;
|
|
12
19
|
permissions?: {
|
|
13
20
|
admin: boolean;
|
|
@@ -16,7 +23,30 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
16
23
|
push: boolean;
|
|
17
24
|
maintain?: boolean;
|
|
18
25
|
};
|
|
19
|
-
owner:
|
|
26
|
+
owner: {
|
|
27
|
+
name?: string | null;
|
|
28
|
+
email?: string | null;
|
|
29
|
+
login: string;
|
|
30
|
+
id: number;
|
|
31
|
+
node_id: string;
|
|
32
|
+
avatar_url: string;
|
|
33
|
+
gravatar_id: string | null;
|
|
34
|
+
url: string;
|
|
35
|
+
html_url: string;
|
|
36
|
+
followers_url: string;
|
|
37
|
+
following_url: string;
|
|
38
|
+
gists_url: string;
|
|
39
|
+
starred_url: string;
|
|
40
|
+
subscriptions_url: string;
|
|
41
|
+
organizations_url: string;
|
|
42
|
+
repos_url: string;
|
|
43
|
+
events_url: string;
|
|
44
|
+
received_events_url: string;
|
|
45
|
+
type: string;
|
|
46
|
+
site_admin: boolean;
|
|
47
|
+
starred_at?: string;
|
|
48
|
+
user_view_type?: string;
|
|
49
|
+
};
|
|
20
50
|
private: boolean;
|
|
21
51
|
html_url: string;
|
|
22
52
|
description: string | null;
|
|
@@ -121,7 +151,14 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
121
151
|
node_id: string;
|
|
122
152
|
name: string;
|
|
123
153
|
full_name: string;
|
|
124
|
-
license:
|
|
154
|
+
license: {
|
|
155
|
+
key: string;
|
|
156
|
+
name: string;
|
|
157
|
+
url: string | null;
|
|
158
|
+
spdx_id: string | null;
|
|
159
|
+
node_id: string;
|
|
160
|
+
html_url?: string;
|
|
161
|
+
} | null;
|
|
125
162
|
forks: number;
|
|
126
163
|
permissions?: {
|
|
127
164
|
admin: boolean;
|
|
@@ -130,7 +167,30 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
130
167
|
push: boolean;
|
|
131
168
|
maintain?: boolean;
|
|
132
169
|
};
|
|
133
|
-
owner:
|
|
170
|
+
owner: {
|
|
171
|
+
name?: string | null;
|
|
172
|
+
email?: string | null;
|
|
173
|
+
login: string;
|
|
174
|
+
id: number;
|
|
175
|
+
node_id: string;
|
|
176
|
+
avatar_url: string;
|
|
177
|
+
gravatar_id: string | null;
|
|
178
|
+
url: string;
|
|
179
|
+
html_url: string;
|
|
180
|
+
followers_url: string;
|
|
181
|
+
following_url: string;
|
|
182
|
+
gists_url: string;
|
|
183
|
+
starred_url: string;
|
|
184
|
+
subscriptions_url: string;
|
|
185
|
+
organizations_url: string;
|
|
186
|
+
repos_url: string;
|
|
187
|
+
events_url: string;
|
|
188
|
+
received_events_url: string;
|
|
189
|
+
type: string;
|
|
190
|
+
site_admin: boolean;
|
|
191
|
+
starred_at?: string;
|
|
192
|
+
user_view_type?: string;
|
|
193
|
+
};
|
|
134
194
|
private: boolean;
|
|
135
195
|
html_url: string;
|
|
136
196
|
description: string | null;
|
|
@@ -228,7 +288,14 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
228
288
|
node_id: string;
|
|
229
289
|
name: string;
|
|
230
290
|
full_name: string;
|
|
231
|
-
license:
|
|
291
|
+
license: {
|
|
292
|
+
key: string;
|
|
293
|
+
name: string;
|
|
294
|
+
url: string | null;
|
|
295
|
+
spdx_id: string | null;
|
|
296
|
+
node_id: string;
|
|
297
|
+
html_url?: string;
|
|
298
|
+
} | null;
|
|
232
299
|
forks: number;
|
|
233
300
|
permissions?: {
|
|
234
301
|
admin: boolean;
|
|
@@ -237,7 +304,30 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
237
304
|
push: boolean;
|
|
238
305
|
maintain?: boolean;
|
|
239
306
|
};
|
|
240
|
-
owner:
|
|
307
|
+
owner: {
|
|
308
|
+
name?: string | null;
|
|
309
|
+
email?: string | null;
|
|
310
|
+
login: string;
|
|
311
|
+
id: number;
|
|
312
|
+
node_id: string;
|
|
313
|
+
avatar_url: string;
|
|
314
|
+
gravatar_id: string | null;
|
|
315
|
+
url: string;
|
|
316
|
+
html_url: string;
|
|
317
|
+
followers_url: string;
|
|
318
|
+
following_url: string;
|
|
319
|
+
gists_url: string;
|
|
320
|
+
starred_url: string;
|
|
321
|
+
subscriptions_url: string;
|
|
322
|
+
organizations_url: string;
|
|
323
|
+
repos_url: string;
|
|
324
|
+
events_url: string;
|
|
325
|
+
received_events_url: string;
|
|
326
|
+
type: string;
|
|
327
|
+
site_admin: boolean;
|
|
328
|
+
starred_at?: string;
|
|
329
|
+
user_view_type?: string;
|
|
330
|
+
};
|
|
241
331
|
private: boolean;
|
|
242
332
|
html_url: string;
|
|
243
333
|
description: string | null;
|
|
@@ -359,7 +449,14 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
359
449
|
node_id: string;
|
|
360
450
|
name: string;
|
|
361
451
|
full_name: string;
|
|
362
|
-
license:
|
|
452
|
+
license: {
|
|
453
|
+
key: string;
|
|
454
|
+
name: string;
|
|
455
|
+
url: string | null;
|
|
456
|
+
spdx_id: string | null;
|
|
457
|
+
node_id: string;
|
|
458
|
+
html_url?: string;
|
|
459
|
+
} | null;
|
|
363
460
|
forks: number;
|
|
364
461
|
permissions?: {
|
|
365
462
|
admin: boolean;
|
|
@@ -368,7 +465,30 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
368
465
|
push: boolean;
|
|
369
466
|
maintain?: boolean;
|
|
370
467
|
};
|
|
371
|
-
owner:
|
|
468
|
+
owner: {
|
|
469
|
+
name?: string | null;
|
|
470
|
+
email?: string | null;
|
|
471
|
+
login: string;
|
|
472
|
+
id: number;
|
|
473
|
+
node_id: string;
|
|
474
|
+
avatar_url: string;
|
|
475
|
+
gravatar_id: string | null;
|
|
476
|
+
url: string;
|
|
477
|
+
html_url: string;
|
|
478
|
+
followers_url: string;
|
|
479
|
+
following_url: string;
|
|
480
|
+
gists_url: string;
|
|
481
|
+
starred_url: string;
|
|
482
|
+
subscriptions_url: string;
|
|
483
|
+
organizations_url: string;
|
|
484
|
+
repos_url: string;
|
|
485
|
+
events_url: string;
|
|
486
|
+
received_events_url: string;
|
|
487
|
+
type: string;
|
|
488
|
+
site_admin: boolean;
|
|
489
|
+
starred_at?: string;
|
|
490
|
+
user_view_type?: string;
|
|
491
|
+
};
|
|
372
492
|
private: boolean;
|
|
373
493
|
html_url: string;
|
|
374
494
|
description: string | null;
|
|
@@ -490,7 +610,14 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
490
610
|
node_id: string;
|
|
491
611
|
name: string;
|
|
492
612
|
full_name: string;
|
|
493
|
-
license:
|
|
613
|
+
license: {
|
|
614
|
+
key: string;
|
|
615
|
+
name: string;
|
|
616
|
+
url: string | null;
|
|
617
|
+
spdx_id: string | null;
|
|
618
|
+
node_id: string;
|
|
619
|
+
html_url?: string;
|
|
620
|
+
} | null;
|
|
494
621
|
forks: number;
|
|
495
622
|
permissions?: {
|
|
496
623
|
admin: boolean;
|
|
@@ -499,7 +626,30 @@ export declare function readyGitHubUserRepositories(token: string): {
|
|
|
499
626
|
push: boolean;
|
|
500
627
|
maintain?: boolean;
|
|
501
628
|
};
|
|
502
|
-
owner:
|
|
629
|
+
owner: {
|
|
630
|
+
name?: string | null;
|
|
631
|
+
email?: string | null;
|
|
632
|
+
login: string;
|
|
633
|
+
id: number;
|
|
634
|
+
node_id: string;
|
|
635
|
+
avatar_url: string;
|
|
636
|
+
gravatar_id: string | null;
|
|
637
|
+
url: string;
|
|
638
|
+
html_url: string;
|
|
639
|
+
followers_url: string;
|
|
640
|
+
following_url: string;
|
|
641
|
+
gists_url: string;
|
|
642
|
+
starred_url: string;
|
|
643
|
+
subscriptions_url: string;
|
|
644
|
+
organizations_url: string;
|
|
645
|
+
repos_url: string;
|
|
646
|
+
events_url: string;
|
|
647
|
+
received_events_url: string;
|
|
648
|
+
type: string;
|
|
649
|
+
site_admin: boolean;
|
|
650
|
+
starred_at?: string;
|
|
651
|
+
user_view_type?: string;
|
|
652
|
+
};
|
|
503
653
|
private: boolean;
|
|
504
654
|
html_url: string;
|
|
505
655
|
description: string | null;
|
package/dist/repl.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{start as e}from"repl";import{readFile as t}from"fs/promises";import*as n from"path";import r from"assert";async function loopPages(e,t){let n=t??10,r=[],i=1;for(;;){let{resultItems:t}=await e({per_page:n,page:i});if(r.push(t),t.length<n)break;i++}return r.flat()}var GitHubApiBase=class{token;constructor(e){this.token=e}get apiOrigin(){return`https://api.github.com`}get apiEndpoint(){return``}get requestHeaders(){return{accept:`application/vnd.github+json`,authorization:`Bearer ${this.token}`,"X-GitHub-Api-Version":`2022-11-28`}}get pageSizeForRequest(){return 10}async getPagedList(e){return await loopPages(async({per_page:t,page:n})=>{let r=new URL(this.apiEndpoint),i={...e??{},per_page:t,page:n};for(let[e,t]of Object.entries(i))r.searchParams.append(e,`${t}`);return{resultItems:await fetch(r,{headers:this.requestHeaders,cache:`no-store`}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}},this.pageSizeForRequest)}async getList(e){let t=new URL(this.apiEndpoint);for(let[n,r]of Object.entries(e??{}))t.searchParams.append(n,`${r}`);return await fetch(t,{headers:this.requestHeaders,cache:`no-store`}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}async get(){return await fetch(this.apiEndpoint,{headers:this.requestHeaders,cache:`no-store`}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}async post(e){return await fetch(this.apiEndpoint,{method:`POST`,headers:this.requestHeaders,body:JSON.stringify(e)}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}async patch(e){return await fetch(this.apiEndpoint,{method:`PATCH`,headers:this.requestHeaders,body:JSON.stringify(e)}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}async delete(){let e=await fetch(this.apiEndpoint,{method:`DELETE`,headers:this.requestHeaders});if(!e.ok)throw Error(e.statusText,{cause:{response:e}})}},GitHubRepoApiBase=class extends GitHubApiBase{owner;repo;constructor(e,t,n){super(e),this.owner=t,this.repo=n}},GitHubIssueApiBase=class extends GitHubRepoApiBase{issueNumber;constructor(e,t,n,r){super(e,t,n),this.issueNumber=r}},GitHubPullApiBase=class extends GitHubRepoApiBase{pullNumber;constructor(e,t,n,r){super(e,t,n),this.pullNumber=r}};function readyGitHubMyIssues(e){return class extends GitHubApiBase{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/issues`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubOrganizationRepositories(e){return class extends GitHubApiBase{org;constructor(t){super(e),this.org=t}get apiEndpoint(){return`${this.apiOrigin}/orgs/${this.org}/repos`}}}function readyGitHubBlob(e){return class extends GitHubRepoApiBase{fileSha;constructor(t,n,r){super(e,t,n),this.fileSha=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs/${this.fileSha}`}}}function readyGitHubBlobs(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs`}}}function readyGitHubIssueComments(e){return class extends GitHubIssueApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}/comments`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubIssue(e){let t=readyGitHubIssueComments(e);return class extends GitHubIssueApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}`}async getComments(){return await new t(this.owner,this.repo,this.issueNumber).getList()}async postComment(...e){return await new t(this.owner,this.repo,this.issueNumber).post(...e)}}}function readyGitHubRepositoryArtifacts(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts`}get pageSizeForRequest(){return 100}async getList(e){return await loopPages(async({per_page:t,page:n})=>{let r=new URL(this.apiEndpoint),i={...e??{},per_page:t,page:n};for(let[e,t]of Object.entries(i))r.searchParams.append(e,`${t}`);return{resultItems:await fetch(r,{headers:this.requestHeaders,cache:`no-store`}).then(async e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});let{artifacts:t}=await e.json();return t})}},this.pageSizeForRequest)}}}function readyGitHubRepositoryArtifact(e){return class extends GitHubRepoApiBase{artifactId;constructor(t,n,r){super(e,t,n),this.artifactId=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts/${this.artifactId}`}async downloadBlob(){let e=`${this.apiEndpoint}/zip`,t=await fetch(e,{headers:this.requestHeaders,cache:`no-store`});if(!t.ok)throw Error(t.statusText,{cause:{response:t}});return await t.blob()}}}function readyGitHubRepositoryBranch(e){return class extends GitHubRepoApiBase{branch;constructor(t,n,r){super(e,t,n),this.branch=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches/${this.branch}`}}}function readyGitHubRepositoryBranches(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubRepositoryCommits(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/commits`}}}function readyGitHubRepositoryIssues(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubReference(e){return class extends GitHubRepoApiBase{ref;constructor(t,n,r){super(e,t,n),this.ref=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs/${this.ref}`}}}function readyGitHubReferenceForGet(e){return class extends GitHubRepoApiBase{ref;constructor(t,n,r){super(e,t,n),this.ref=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/ref/${this.ref}`}}}function readyGitHubPullCommits(e){return class extends GitHubPullApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/commits`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubPullReviewers(e){return class extends GitHubPullApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/requested_reviewers`}}}function readyGitHubRepositoryPull(e){let t=readyGitHubPullCommits(e),n=readyGitHubPullReviewers(e);return class extends GitHubPullApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}`}async getCommits(){return await new t(this.owner,this.repo,this.pullNumber).getList()}async getReviewers(){return await new n(this.owner,this.repo,this.pullNumber).get()}async postReviewers(...e){return await new n(this.owner,this.repo,this.pullNumber).post(...e)}}}function readyGitHubRepositoryPulls(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubRepositoryReferences(e){class GitHubRepositoryMatchingReferences extends GitHubRepoApiBase{refName;constructor(t,n,r){super(e,t,n),this.refName=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/matching-refs/${this.refName}`}}return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs`}async getMatchingList(e){return await new GitHubRepositoryMatchingReferences(this.owner,this.repo,e).getList()}}}function readyGitHubRepositoryReleases(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubRepositoryLatestRelease(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases/latest`}}}function readyGitHubRepositoryRuns(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/runs`}get pageSizeForRequest(){return 100}async getList(e){return await loopPages(async({per_page:t,page:n})=>{let r=new URL(this.apiEndpoint),i={...e??{},per_page:t,page:n};for(let[e,t]of Object.entries(i))r.searchParams.append(e,`${t}`);return{resultItems:await fetch(r,{headers:this.requestHeaders,cache:`no-store`}).then(async e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});let{workflow_runs:t}=await e.json();return t})}},this.pageSizeForRequest)}}}function readyGitHubTree(e){return class extends GitHubRepoApiBase{treeSha;constructor(t,n,r){super(e,t,n),this.treeSha=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees/${this.treeSha}?recursive=true`}}}function readyGitHubRepositoryTrees(e){return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees`}}}function readyGitHubRepository(e){let t=readyGitHubBlob(e),n=readyGitHubBlobs(e),r=readyGitHubIssue(e),i=readyGitHubReference(e),a=readyGitHubReferenceForGet(e),o=readyGitHubRepositoryArtifacts(e),s=readyGitHubRepositoryArtifact(e),c=readyGitHubRepositoryIssues(e),l=readyGitHubRepositoryBranch(e),u=readyGitHubRepositoryBranches(e),d=readyGitHubRepositoryCommits(e),f=readyGitHubRepositoryPull(e),p=readyGitHubRepositoryPulls(e),m=readyGitHubRepositoryReferences(e),h=readyGitHubRepositoryReleases(e),g=readyGitHubRepositoryLatestRelease(e),_=readyGitHubRepositoryRuns(e),v=readyGitHubRepositoryTrees(e),y=readyGitHubTree(e);return class extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}`}async getArtifacts(e){return await new o(this.owner,this.repo).getList(e)}async getArtifact(e){return await new s(this.owner,this.repo,e).get()}async getArtifactZipBlob(e){return await new s(this.owner,this.repo,e).downloadBlob()}async getBranches(){return await new u(this.owner,this.repo).getList()}async getBranch(e){return await new l(this.owner,this.repo,e).get()}async getReferences(e){return await new m(this.owner,this.repo).getMatchingList(e)}async getBranchReferences(){return await new m(this.owner,this.repo).getMatchingList(`heads/`)}async getTagReferences(){return await new m(this.owner,this.repo).getMatchingList(`tags/`)}async postReference(...e){return await new m(this.owner,this.repo).post(...e)}async getReference(e){return await new a(this.owner,this.repo,e).get()}async getBranchReference(e){return await new a(this.owner,this.repo,`heads/${e}`).get()}async getTagReference(e){return await new a(this.owner,this.repo,`tags/${e}`).get()}async patchReference(e,...t){return await new i(this.owner,this.repo,e).patch(...t)}async deleteReference(e){return await new i(this.owner,this.repo,e).delete()}async getBlob(e){return await new t(this.owner,this.repo,e).get()}async postBlob(...e){return await new n(this.owner,this.repo).post(...e)}async getTree(e){return await new y(this.owner,this.repo,e).get()}async postTree(...e){return await new v(this.owner,this.repo).post(...e)}async getIssues(e){return await new c(this.owner,this.repo).getList(e)}async postIssue(...e){return await new c(this.owner,this.repo).post(...e)}issue(e){return new r(this.owner,this.repo,e)}async getIssue(e){return await new r(this.owner,this.repo,e).get()}async patchIssue(e,...t){return await new r(this.owner,this.repo,e).patch(...t)}async getPulls(e){return await new p(this.owner,this.repo).getList(e)}async postPull(...e){return await new p(this.owner,this.repo).post(...e)}pull(e){return new f(this.owner,this.repo,e)}async getPull(e){return await new f(this.owner,this.repo,e).get()}async patchPull(e,...t){return await new f(this.owner,this.repo,e).patch(...t)}async getReleases(e){return await new h(this.owner,this.repo).getList(e)}async postRelease(...e){return await new h(this.owner,this.repo).post(...e)}async getLatestRelease(){return await new g(this.owner,this.repo).get()}async postCommit(...e){return await new d(this.owner,this.repo).post(...e)}async getRuns(e){return await new _(this.owner,this.repo).getList(e)}}}function readyGitHubUser(e){return class GitHubUser extends GitHubApiBase{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user`}}}function readyGitHubUserOrganizations(e){return class extends GitHubApiBase{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/orgs`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubUserRepositories(e){return class extends GitHubApiBase{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/repos`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubClasses(e){return{GitHubMyIssues:readyGitHubMyIssues(e),GitHubOrganizationRepositories:readyGitHubOrganizationRepositories(e),GitHubRepository:readyGitHubRepository(e),GitHubRepositoryIssues:readyGitHubRepositoryIssues(e),GitHubUser:readyGitHubUser(e),GitHubUserOrganizations:readyGitHubUserOrganizations(e),GitHubUserRepositories:readyGitHubUserRepositories(e)}}var GitHubFacade=class{token;githubClasses;constructor(e){this.token=e,this.githubClasses=readyGitHubClasses(e)}async getMe(){return await new this.githubClasses.GitHubUser().get()}async getMyOrganizations(){let{GitHubUserOrganizations:e,GitHubOrganizationRepositories:t}=this.githubClasses;return(await new e().getList()).map(e=>({...e,async getRepositories(){return await new t(e.login).getList()}}))}async getMyRepositories(){let{GitHubUserRepositories:e,GitHubRepositoryIssues:t}=this.githubClasses;return(await new e().getList()).map(e=>({...e,async getIssues(){return await new t(e.owner.login,e.name).getList()},async postIssue(...n){return await new t(e.owner.login,e.name).post(...n)}}))}async getMyIssues(){let{GitHubMyIssues:e}=this.githubClasses;return await new e().getList()}repo(e,t){let{GitHubRepository:n}=this.githubClasses;return new n(e,t)}};async function executeScriptFile(e,n){await Function(`{github}`,`return new Promise(async (resolve) => {
|
|
1
|
+
import{start as e}from"repl";import{readFile as t}from"fs/promises";import*as n from"path";import r from"assert";async function loopPages(e,t){let n=t??10,r=[],i=1;for(;;){let{resultItems:t}=await e({per_page:n,page:i});if(r.push(t),t.length<n)break;i++}return r.flat()}var GitHubApiBase=class{token;constructor(e){this.token=e}get apiOrigin(){return`https://api.github.com`}get apiEndpoint(){return``}get requestHeaders(){return{accept:`application/vnd.github+json`,authorization:`Bearer ${this.token}`,"X-GitHub-Api-Version":`2022-11-28`}}get pageSizeForRequest(){return 10}async getPagedList(e){return await loopPages(async({per_page:t,page:n})=>{let r=new URL(this.apiEndpoint),i={...e??{},per_page:t,page:n};for(let[e,t]of Object.entries(i))r.searchParams.append(e,`${t}`);return{resultItems:await fetch(r,{headers:this.requestHeaders,cache:`no-store`}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}},this.pageSizeForRequest)}async getList(e){let t=new URL(this.apiEndpoint);for(let[n,r]of Object.entries(e??{}))t.searchParams.append(n,`${r}`);return await fetch(t,{headers:this.requestHeaders,cache:`no-store`}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}async get(){return await fetch(this.apiEndpoint,{headers:this.requestHeaders,cache:`no-store`}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}async post(e){return await fetch(this.apiEndpoint,{method:`POST`,headers:this.requestHeaders,body:JSON.stringify(e)}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}async patch(e){return await fetch(this.apiEndpoint,{method:`PATCH`,headers:this.requestHeaders,body:JSON.stringify(e)}).then(e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});return e.json()})}async delete(){let e=await fetch(this.apiEndpoint,{method:`DELETE`,headers:this.requestHeaders});if(!e.ok)throw Error(e.statusText,{cause:{response:e}})}},GitHubRepoApiBase=class extends GitHubApiBase{owner;repo;constructor(e,t,n){super(e),this.owner=t,this.repo=n}},GitHubIssueApiBase=class extends GitHubRepoApiBase{issueNumber;constructor(e,t,n,r){super(e,t,n),this.issueNumber=r}},GitHubPullApiBase=class extends GitHubRepoApiBase{pullNumber;constructor(e,t,n,r){super(e,t,n),this.pullNumber=r}};function readyGitHubMyIssues(e){return class GitHubMyIssues extends GitHubApiBase{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/issues`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubOrganizationRepositories(e){return class GitHubOrganizationRepositories extends GitHubApiBase{org;constructor(t){super(e),this.org=t}get apiEndpoint(){return`${this.apiOrigin}/orgs/${this.org}/repos`}}}function readyGitHubBlob(e){return class GitHubBlob extends GitHubRepoApiBase{fileSha;constructor(t,n,r){super(e,t,n),this.fileSha=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs/${this.fileSha}`}}}function readyGitHubBlobs(e){return class GitHubBlobs extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs`}}}function readyGitHubIssueComments(e){return class GitHubIssueComments extends GitHubIssueApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}/comments`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubIssue(e){let t=readyGitHubIssueComments(e);return class GitHubIssue extends GitHubIssueApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}`}async getComments(){return await new t(this.owner,this.repo,this.issueNumber).getList()}async postComment(...e){return await new t(this.owner,this.repo,this.issueNumber).post(...e)}}}function readyGitHubRepositoryArtifacts(e){return class GitHubRepositoryArtifacts extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts`}get pageSizeForRequest(){return 100}async getList(e){return await loopPages(async({per_page:t,page:n})=>{let r=new URL(this.apiEndpoint),i={...e??{},per_page:t,page:n};for(let[e,t]of Object.entries(i))r.searchParams.append(e,`${t}`);return{resultItems:await fetch(r,{headers:this.requestHeaders,cache:`no-store`}).then(async e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});let{artifacts:t}=await e.json();return t})}},this.pageSizeForRequest)}}}function readyGitHubRepositoryArtifact(e){return class GitHubRepositoryArtifact extends GitHubRepoApiBase{artifactId;constructor(t,n,r){super(e,t,n),this.artifactId=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts/${this.artifactId}`}async downloadBlob(){let e=`${this.apiEndpoint}/zip`,t=await fetch(e,{headers:this.requestHeaders,cache:`no-store`});if(!t.ok)throw Error(t.statusText,{cause:{response:t}});return await t.blob()}}}function readyGitHubRepositoryBranch(e){return class GitHubRepositoryBranch extends GitHubRepoApiBase{branch;constructor(t,n,r){super(e,t,n),this.branch=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches/${this.branch}`}}}function readyGitHubRepositoryBranches(e){return class GitHubRepositoryBranches extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubRepositoryCommits(e){return class GitHubRepositoryCommits extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/commits`}}}function readyGitHubRepositoryIssues(e){return class GitHubRepositoryIssues extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubReference(e){return class GitHubReference extends GitHubRepoApiBase{ref;constructor(t,n,r){super(e,t,n),this.ref=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs/${this.ref}`}}}function readyGitHubReferenceForGet(e){return class GitHubReferenceForGet extends GitHubRepoApiBase{ref;constructor(t,n,r){super(e,t,n),this.ref=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/ref/${this.ref}`}}}function readyGitHubPullCommits(e){return class GitHubPullCommits extends GitHubPullApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/commits`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubPullReviewers(e){return class GitHubPullReviewers extends GitHubPullApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/requested_reviewers`}}}function readyGitHubRepositoryPull(e){let t=readyGitHubPullCommits(e),n=readyGitHubPullReviewers(e);return class GitHubRepositoryPull extends GitHubPullApiBase{constructor(t,n,r){super(e,t,n,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}`}async getCommits(){return await new t(this.owner,this.repo,this.pullNumber).getList()}async getReviewers(){return await new n(this.owner,this.repo,this.pullNumber).get()}async postReviewers(...e){return await new n(this.owner,this.repo,this.pullNumber).post(...e)}}}function readyGitHubRepositoryPulls(e){return class GitHubRepositoryPulls extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubRepositoryReferences(e){class GitHubRepositoryMatchingReferences extends GitHubRepoApiBase{refName;constructor(t,n,r){super(e,t,n),this.refName=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/matching-refs/${this.refName}`}}return class GitHubRepositoryReferences extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs`}async getMatchingList(e){return await new GitHubRepositoryMatchingReferences(this.owner,this.repo,e).getList()}}}function readyGitHubRepositoryReleases(e){return class GitHubRepositoryReleases extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubRepositoryLatestRelease(e){return class GitHubRepositoryLatestRelease extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases/latest`}}}function readyGitHubRepositoryRuns(e){return class GitHubRepositoryRuns extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/runs`}get pageSizeForRequest(){return 100}async getList(e){return await loopPages(async({per_page:t,page:n})=>{let r=new URL(this.apiEndpoint),i={...e??{},per_page:t,page:n};for(let[e,t]of Object.entries(i))r.searchParams.append(e,`${t}`);return{resultItems:await fetch(r,{headers:this.requestHeaders,cache:`no-store`}).then(async e=>{if(!e.ok)throw Error(e.statusText,{cause:{response:e}});let{workflow_runs:t}=await e.json();return t})}},this.pageSizeForRequest)}}}function readyGitHubTree(e){return class GitHubTree extends GitHubRepoApiBase{treeSha;constructor(t,n,r){super(e,t,n),this.treeSha=r}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees/${this.treeSha}?recursive=true`}}}function readyGitHubRepositoryTrees(e){return class GitHubRepositoryTrees extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees`}}}function readyGitHubRepository(e){let t=readyGitHubBlob(e),n=readyGitHubBlobs(e),r=readyGitHubIssue(e),i=readyGitHubReference(e),a=readyGitHubReferenceForGet(e),o=readyGitHubRepositoryArtifacts(e),s=readyGitHubRepositoryArtifact(e),c=readyGitHubRepositoryIssues(e),l=readyGitHubRepositoryBranch(e),u=readyGitHubRepositoryBranches(e),d=readyGitHubRepositoryCommits(e),f=readyGitHubRepositoryPull(e),p=readyGitHubRepositoryPulls(e),m=readyGitHubRepositoryReferences(e),h=readyGitHubRepositoryReleases(e),g=readyGitHubRepositoryLatestRelease(e),_=readyGitHubRepositoryRuns(e),v=readyGitHubRepositoryTrees(e),y=readyGitHubTree(e);return class GitHubRepository extends GitHubRepoApiBase{constructor(t,n){super(e,t,n)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}`}async getArtifacts(e){return await new o(this.owner,this.repo).getList(e)}async getArtifact(e){return await new s(this.owner,this.repo,e).get()}async getArtifactZipBlob(e){return await new s(this.owner,this.repo,e).downloadBlob()}async getBranches(){return await new u(this.owner,this.repo).getList()}async getBranch(e){return await new l(this.owner,this.repo,e).get()}async getReferences(e){return await new m(this.owner,this.repo).getMatchingList(e)}async getBranchReferences(){return await new m(this.owner,this.repo).getMatchingList(`heads/`)}async getTagReferences(){return await new m(this.owner,this.repo).getMatchingList(`tags/`)}async postReference(...e){return await new m(this.owner,this.repo).post(...e)}async getReference(e){return await new a(this.owner,this.repo,e).get()}async getBranchReference(e){return await new a(this.owner,this.repo,`heads/${e}`).get()}async getTagReference(e){return await new a(this.owner,this.repo,`tags/${e}`).get()}async patchReference(e,...t){return await new i(this.owner,this.repo,e).patch(...t)}async deleteReference(e){return await new i(this.owner,this.repo,e).delete()}async getBlob(e){return await new t(this.owner,this.repo,e).get()}async postBlob(...e){return await new n(this.owner,this.repo).post(...e)}async getTree(e){return await new y(this.owner,this.repo,e).get()}async postTree(...e){return await new v(this.owner,this.repo).post(...e)}async getIssues(e){return await new c(this.owner,this.repo).getList(e)}async postIssue(...e){return await new c(this.owner,this.repo).post(...e)}issue(e){return new r(this.owner,this.repo,e)}async getIssue(e){return await new r(this.owner,this.repo,e).get()}async patchIssue(e,...t){return await new r(this.owner,this.repo,e).patch(...t)}async getPulls(e){return await new p(this.owner,this.repo).getList(e)}async postPull(...e){return await new p(this.owner,this.repo).post(...e)}pull(e){return new f(this.owner,this.repo,e)}async getPull(e){return await new f(this.owner,this.repo,e).get()}async patchPull(e,...t){return await new f(this.owner,this.repo,e).patch(...t)}async getReleases(e){return await new h(this.owner,this.repo).getList(e)}async postRelease(...e){return await new h(this.owner,this.repo).post(...e)}async getLatestRelease(){return await new g(this.owner,this.repo).get()}async postCommit(...e){return await new d(this.owner,this.repo).post(...e)}async getRuns(e){return await new _(this.owner,this.repo).getList(e)}}}function readyGitHubUser(e){return class GitHubUser extends GitHubApiBase{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user`}}}function readyGitHubUserOrganizations(e){return class GitHubUserOrganizations extends GitHubApiBase{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/orgs`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubUserRepositories(e){return class GitHubUserRepositories extends GitHubApiBase{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/repos`}get pageSizeForRequest(){return 100}async getList(e){return await this.getPagedList(e)}}}function readyGitHubClasses(e){return{GitHubMyIssues:readyGitHubMyIssues(e),GitHubOrganizationRepositories:readyGitHubOrganizationRepositories(e),GitHubRepository:readyGitHubRepository(e),GitHubRepositoryIssues:readyGitHubRepositoryIssues(e),GitHubUser:readyGitHubUser(e),GitHubUserOrganizations:readyGitHubUserOrganizations(e),GitHubUserRepositories:readyGitHubUserRepositories(e)}}var GitHubFacade=class{token;githubClasses;constructor(e){this.token=e,this.githubClasses=readyGitHubClasses(e)}async getMe(){return await new this.githubClasses.GitHubUser().get()}async getMyOrganizations(){let{GitHubUserOrganizations:e,GitHubOrganizationRepositories:t}=this.githubClasses;return(await new e().getList()).map(e=>({...e,async getRepositories(){return await new t(e.login).getList()}}))}async getMyRepositories(){let{GitHubUserRepositories:e,GitHubRepositoryIssues:t}=this.githubClasses;return(await new e().getList()).map(e=>({...e,async getIssues(){return await new t(e.owner.login,e.name).getList()},async postIssue(...n){return await new t(e.owner.login,e.name).post(...n)}}))}async getMyIssues(){let{GitHubMyIssues:e}=this.githubClasses;return await new e().getList()}repo(e,t){let{GitHubRepository:n}=this.githubClasses;return new n(e,t)}};async function executeScriptFile(e,n){await Function(`{github}`,`return new Promise(async (resolve) => {
|
|
2
2
|
${await t(e,{encoding:`utf8`})}
|
|
3
3
|
resolve();
|
|
4
4
|
});`)({github:n})}async function main(){let t=process.env.GITHUB_TOKEN;r(t!=null&&t!==``,`GITHUB_TOKEN environment variable is not set`);let i=new GitHubFacade(t),[a,o,s]=process.argv,c=n.resolve(process.cwd(),`/scripts/${s}`);if(s!=null){await executeScriptFile(c,i);return}let l=e({prompt:`github> `});l.context.github=i}main().catch(console.error);export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomsd/github-repo-js",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "tsdown && tsc -p tsconfig.types.json",
|
|
19
|
+
"build": "tsdown && tsc -p tsconfig.types.json && tsc-alias -p tsconfig.types.json",
|
|
20
20
|
"test": "vitest"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [],
|
|
@@ -35,9 +35,11 @@
|
|
|
35
35
|
"@octokit/types": "16.0.0",
|
|
36
36
|
"@tsconfig/node24": "24.0.4",
|
|
37
37
|
"@types/node": "25.6.0",
|
|
38
|
+
"prettier": "3.8.3",
|
|
39
|
+
"tsc-alias": "1.8.16",
|
|
38
40
|
"tsdown": "0.21.9",
|
|
39
41
|
"tsx": "4.21.0",
|
|
40
|
-
"typescript": "6.0.
|
|
42
|
+
"typescript": "6.0.3",
|
|
41
43
|
"vitest": "4.1.4"
|
|
42
44
|
}
|
|
43
45
|
}
|