@tomsd/github-repo-js 0.2.1 → 0.2.3
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/README.md +3 -3
- package/dist/index.d.ts +443 -5094
- package/dist/index.iife.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/modules/base.d.ts +31 -0
- package/dist/modules/blob.d.ts +68 -0
- package/dist/modules/blobs.d.ts +67 -0
- package/dist/modules/github-classes.d.ts +4647 -0
- package/dist/modules/issue-comments.d.ts +101 -0
- package/dist/modules/issue.d.ts +330 -0
- package/dist/modules/my-issues.d.ts +289 -0
- package/dist/modules/organization-audit-log.d.ts +22 -0
- package/dist/modules/organization-repositories.d.ts +591 -0
- package/dist/modules/pull-commits.d.ts +177 -0
- package/dist/modules/pull-reviewers.d.ts +41 -0
- package/dist/modules/reference-get.d.ts +67 -0
- package/dist/modules/reference.d.ts +73 -0
- package/dist/modules/repository-artifact.d.ts +118 -0
- package/dist/modules/repository-artifacts.d.ts +118 -0
- package/dist/modules/repository-branch.d.ts +82 -0
- package/dist/modules/repository-branches.d.ts +66 -0
- package/dist/modules/repository-commits.d.ts +211 -0
- package/dist/modules/repository-issues.d.ts +317 -0
- package/dist/modules/repository-latest-release.d.ts +21 -0
- package/dist/modules/repository-pull.d.ts +458 -0
- package/dist/modules/repository-pulls.d.ts +369 -0
- package/dist/modules/repository-references.d.ts +82 -0
- package/dist/modules/repository-releases.d.ts +171 -0
- package/dist/modules/repository-runs.d.ts +206 -0
- package/dist/modules/repository-trees.d.ts +99 -0
- package/dist/modules/repository.d.ts +2267 -0
- package/dist/modules/tree.d.ts +82 -0
- package/dist/modules/user-organizations.d.ts +84 -0
- package/dist/modules/user-repositories.d.ts +597 -0
- package/dist/modules/user.d.ts +500 -0
- package/dist/repl.mjs +4 -0
- package/dist/utils/index.d.ts +6 -0
- package/package.json +8 -8
- package/dist/index.global.js +0 -1
- package/dist/index.js +0 -1
- package/dist/repl.js +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var GitHubRepoJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});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)}};return e.GitHubFacade=GitHubFacade,e})({});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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)}};export{GitHubFacade};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare class GitHubApiBase<Item, ApiRequestBody> {
|
|
2
|
+
token: string;
|
|
3
|
+
constructor(token: string);
|
|
4
|
+
get apiOrigin(): string;
|
|
5
|
+
get apiEndpoint(): string;
|
|
6
|
+
get requestHeaders(): {
|
|
7
|
+
accept: string;
|
|
8
|
+
authorization: string;
|
|
9
|
+
"X-GitHub-Api-Version": string;
|
|
10
|
+
};
|
|
11
|
+
get pageSizeForRequest(): number;
|
|
12
|
+
getPagedList(query?: Record<string, string>): Promise<Item[]>;
|
|
13
|
+
getList(query?: Record<string, string>): Promise<Item[]>;
|
|
14
|
+
get(): Promise<Item>;
|
|
15
|
+
post(body: ApiRequestBody): Promise<Item>;
|
|
16
|
+
patch(body: ApiRequestBody): Promise<Item>;
|
|
17
|
+
delete(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare class GitHubRepoApiBase<Item, ApiRequestBody> extends GitHubApiBase<Item, ApiRequestBody> {
|
|
20
|
+
owner: string;
|
|
21
|
+
repo: string;
|
|
22
|
+
constructor(token: string, owner: string, repo: string);
|
|
23
|
+
}
|
|
24
|
+
export declare class GitHubIssueApiBase<Item, ApiRequestBody> extends GitHubRepoApiBase<Item, ApiRequestBody> {
|
|
25
|
+
issueNumber: number;
|
|
26
|
+
constructor(token: string, owner: string, repo: string, issueNumber: number);
|
|
27
|
+
}
|
|
28
|
+
export declare class GitHubPullApiBase<Item, ApiRequestBody> extends GitHubRepoApiBase<Item, ApiRequestBody> {
|
|
29
|
+
pullNumber: number;
|
|
30
|
+
constructor(token: string, owner: string, repo: string, pullNumber: number);
|
|
31
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare function readyGitHubBlob(token: string): {
|
|
2
|
+
new (owner: string, repo: string, fileSha: string): {
|
|
3
|
+
fileSha: string;
|
|
4
|
+
get apiEndpoint(): string;
|
|
5
|
+
owner: string;
|
|
6
|
+
repo: string;
|
|
7
|
+
token: string;
|
|
8
|
+
get apiOrigin(): string;
|
|
9
|
+
get requestHeaders(): {
|
|
10
|
+
accept: string;
|
|
11
|
+
authorization: string;
|
|
12
|
+
"X-GitHub-Api-Version": string;
|
|
13
|
+
};
|
|
14
|
+
get pageSizeForRequest(): number;
|
|
15
|
+
getPagedList(query?: Record<string, string>): Promise<{
|
|
16
|
+
content: string;
|
|
17
|
+
encoding: string;
|
|
18
|
+
url: string;
|
|
19
|
+
sha: string;
|
|
20
|
+
size: number | null;
|
|
21
|
+
node_id: string;
|
|
22
|
+
highlighted_content?: string;
|
|
23
|
+
}[]>;
|
|
24
|
+
getList(query?: Record<string, string>): Promise<{
|
|
25
|
+
content: string;
|
|
26
|
+
encoding: string;
|
|
27
|
+
url: string;
|
|
28
|
+
sha: string;
|
|
29
|
+
size: number | null;
|
|
30
|
+
node_id: string;
|
|
31
|
+
highlighted_content?: string;
|
|
32
|
+
}[]>;
|
|
33
|
+
get(): Promise<{
|
|
34
|
+
content: string;
|
|
35
|
+
encoding: string;
|
|
36
|
+
url: string;
|
|
37
|
+
sha: string;
|
|
38
|
+
size: number | null;
|
|
39
|
+
node_id: string;
|
|
40
|
+
highlighted_content?: string;
|
|
41
|
+
}>;
|
|
42
|
+
post(body: {
|
|
43
|
+
content: string;
|
|
44
|
+
encoding?: string;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
content: string;
|
|
47
|
+
encoding: string;
|
|
48
|
+
url: string;
|
|
49
|
+
sha: string;
|
|
50
|
+
size: number | null;
|
|
51
|
+
node_id: string;
|
|
52
|
+
highlighted_content?: string;
|
|
53
|
+
}>;
|
|
54
|
+
patch(body: {
|
|
55
|
+
content: string;
|
|
56
|
+
encoding?: string;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
content: string;
|
|
59
|
+
encoding: string;
|
|
60
|
+
url: string;
|
|
61
|
+
sha: string;
|
|
62
|
+
size: number | null;
|
|
63
|
+
node_id: string;
|
|
64
|
+
highlighted_content?: string;
|
|
65
|
+
}>;
|
|
66
|
+
delete(): Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare function readyGitHubBlobs(token: string): {
|
|
2
|
+
new (owner: string, repo: string): {
|
|
3
|
+
get apiEndpoint(): string;
|
|
4
|
+
owner: string;
|
|
5
|
+
repo: string;
|
|
6
|
+
token: string;
|
|
7
|
+
get apiOrigin(): string;
|
|
8
|
+
get requestHeaders(): {
|
|
9
|
+
accept: string;
|
|
10
|
+
authorization: string;
|
|
11
|
+
"X-GitHub-Api-Version": string;
|
|
12
|
+
};
|
|
13
|
+
get pageSizeForRequest(): number;
|
|
14
|
+
getPagedList(query?: Record<string, string>): Promise<{
|
|
15
|
+
content: string;
|
|
16
|
+
encoding: string;
|
|
17
|
+
url: string;
|
|
18
|
+
sha: string;
|
|
19
|
+
size: number | null;
|
|
20
|
+
node_id: string;
|
|
21
|
+
highlighted_content?: string;
|
|
22
|
+
}[]>;
|
|
23
|
+
getList(query?: Record<string, string>): Promise<{
|
|
24
|
+
content: string;
|
|
25
|
+
encoding: string;
|
|
26
|
+
url: string;
|
|
27
|
+
sha: string;
|
|
28
|
+
size: number | null;
|
|
29
|
+
node_id: string;
|
|
30
|
+
highlighted_content?: string;
|
|
31
|
+
}[]>;
|
|
32
|
+
get(): Promise<{
|
|
33
|
+
content: string;
|
|
34
|
+
encoding: string;
|
|
35
|
+
url: string;
|
|
36
|
+
sha: string;
|
|
37
|
+
size: number | null;
|
|
38
|
+
node_id: string;
|
|
39
|
+
highlighted_content?: string;
|
|
40
|
+
}>;
|
|
41
|
+
post(body: {
|
|
42
|
+
content: string;
|
|
43
|
+
encoding?: string;
|
|
44
|
+
}): Promise<{
|
|
45
|
+
content: string;
|
|
46
|
+
encoding: string;
|
|
47
|
+
url: string;
|
|
48
|
+
sha: string;
|
|
49
|
+
size: number | null;
|
|
50
|
+
node_id: string;
|
|
51
|
+
highlighted_content?: string;
|
|
52
|
+
}>;
|
|
53
|
+
patch(body: {
|
|
54
|
+
content: string;
|
|
55
|
+
encoding?: string;
|
|
56
|
+
}): Promise<{
|
|
57
|
+
content: string;
|
|
58
|
+
encoding: string;
|
|
59
|
+
url: string;
|
|
60
|
+
sha: string;
|
|
61
|
+
size: number | null;
|
|
62
|
+
node_id: string;
|
|
63
|
+
highlighted_content?: string;
|
|
64
|
+
}>;
|
|
65
|
+
delete(): Promise<void>;
|
|
66
|
+
};
|
|
67
|
+
};
|