@tomsd/github-repo-js 0.2.1 → 0.2.2
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.global.js +1 -1
- package/dist/index.js +1 -1
- package/dist/repl.js +3 -3
- package/package.json +3 -3
package/dist/index.global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var GitHubRepoJs=(()=>{var l=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var pt=(e,t)=>{for(var r in t)l(e,r,{get:t[r],enumerable:!0})},at=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ot(t))!nt.call(e,o)&&o!==r&&l(e,o,{get:()=>t[o],enumerable:!(s=it(t,o))||s.enumerable});return e};var ut=e=>at(l({},"__esModule",{value:!0}),e);var gt={};pt(gt,{GitHubFacade:()=>R});async function m(e,t){let r=t??10,s=[],o=1;for(;;){let{resultItems:a}=await e({per_page:r,page:o});if(s.push(a),a.length<r)break;o++}return s.flat()}var ct="https://api.github.com",u=class{token;constructor(t){this.token=t}get apiOrigin(){return ct}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(t){return await m(async({per_page:r,page:s})=>{let o=new URL(this.apiEndpoint),a={...t??{},per_page:r,page:s};for(let[p,c]of Object.entries(a))o.searchParams.append(p,`${c}`);return{resultItems:await fetch(o,{headers:this.requestHeaders,cache:"no-store"}).then(p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});return p.json()})}},this.pageSizeForRequest)}async getList(t){let r=new URL(this.apiEndpoint);for(let[o,a]of Object.entries(t??{}))r.searchParams.append(o,`${a}`);return await fetch(r,{headers:this.requestHeaders,cache:"no-store"}).then(o=>{if(!o.ok)throw new Error(o.statusText,{cause:{response:o}});return o.json()})}async get(){return await fetch(this.apiEndpoint,{headers:this.requestHeaders,cache:"no-store"}).then(r=>{if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return r.json()})}async post(t){return await fetch(this.apiEndpoint,{method:"POST",headers:this.requestHeaders,body:JSON.stringify(t)}).then(s=>{if(!s.ok)throw new Error(s.statusText,{cause:{response:s}});return s.json()})}async patch(t){return await fetch(this.apiEndpoint,{method:"PATCH",headers:this.requestHeaders,body:JSON.stringify(t)}).then(s=>{if(!s.ok)throw new Error(s.statusText,{cause:{response:s}});return s.json()})}async delete(){let t=await fetch(this.apiEndpoint,{method:"DELETE",headers:this.requestHeaders});if(!t.ok)throw new Error(t.statusText,{cause:{response:t}})}},n=class extends u{owner;repo;constructor(t,r,s){super(t),this.owner=r,this.repo=s}},h=class extends n{issueNumber;constructor(t,r,s,o){super(t,r,s),this.issueNumber=o}},g=class extends n{pullNumber;constructor(t,r,s,o){super(t,r,s),this.pullNumber=o}};function H(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function T(e){return class extends u{org;constructor(t){super(e),this.org=t}get apiEndpoint(){return`${this.apiOrigin}/orgs/${this.org}/repos`}}}function $(e){return class extends n{fileSha;constructor(t,r,s){super(e,t,r),this.fileSha=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs/${this.fileSha}`}}}function x(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs`}}}function P(e){return class extends h{constructor(t,r,s){super(e,t,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}/comments`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function O(e){let t=P(e);return class extends h{constructor(r,s,o){super(e,r,s,o)}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(...r){return await new t(this.owner,this.repo,this.issueNumber).post(...r)}}}function B(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts`}get pageSizeForRequest(){return 100}async getList(t){return await m(async({per_page:r,page:s})=>{let o=new URL(this.apiEndpoint),a={...t??{},per_page:r,page:s};for(let[p,c]of Object.entries(a))o.searchParams.append(p,`${c}`);return{resultItems:await fetch(o,{headers:this.requestHeaders,cache:"no-store"}).then(async p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});let{artifacts:c}=await p.json();return c})}},this.pageSizeForRequest)}}}function I(e){return class extends n{artifactId;constructor(t,r,s){super(e,t,r),this.artifactId=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts/${this.artifactId}`}async downloadBlob(){let t=`${this.apiEndpoint}/zip`,r=await fetch(t,{headers:this.requestHeaders,cache:"no-store"});if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return await r.blob()}}}function A(e){return class extends n{branch;constructor(t,r,s){super(e,t,r),this.branch=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches/${this.branch}`}}}function q(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function L(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/commits`}}}function f(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function S(e){return class extends n{ref;constructor(t,r,s){super(e,t,r),this.ref=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs/${this.ref}`}}}function v(e){return class extends n{ref;constructor(t,r,s){super(e,t,r),this.ref=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/ref/${this.ref}`}}}function C(e){return class extends g{constructor(t,r,s){super(e,t,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/commits`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function k(e){return class extends g{constructor(t,r,s){super(e,t,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/requested_reviewers`}}}function z(e){let t=C(e),r=k(e);return class extends g{constructor(s,o,a){super(e,s,o,a)}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 r(this.owner,this.repo,this.pullNumber).get()}async postReviewers(...s){return await new r(this.owner,this.repo,this.pullNumber).post(...s)}}}function _(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function N(e){class t extends n{refName;constructor(s,o,a){super(e,s,o),this.refName=a}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/matching-refs/${this.refName}`}}return class extends n{constructor(r,s){super(e,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs`}async getMatchingList(r){return await new t(this.owner,this.repo,r).getList()}}}function U(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function F(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases/latest`}}}function M(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/runs`}get pageSizeForRequest(){return 100}async getList(t){return await m(async({per_page:r,page:s})=>{let o=new URL(this.apiEndpoint),a={...t??{},per_page:r,page:s};for(let[p,c]of Object.entries(a))o.searchParams.append(p,`${c}`);return{resultItems:await fetch(o,{headers:this.requestHeaders,cache:"no-store"}).then(async p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});let{workflow_runs:c}=await p.json();return c})}},this.pageSizeForRequest)}}}function j(e){return class extends n{treeSha;constructor(t,r,s){super(e,t,r),this.treeSha=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees/${this.treeSha}?recursive=true`}}}function J(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees`}}}function D(e){let t=$(e),r=x(e),s=O(e),o=S(e),a=v(e),y=B(e),p=I(e),c=f(e),Q=A(e),W=q(e),Y=L(e),b=z(e),G=_(e),w=N(e),E=U(e),tt=F(e),et=M(e),rt=J(e),st=j(e);return class extends n{constructor(i,d){super(e,i,d)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}`}async getArtifacts(i){return await new y(this.owner,this.repo).getList(i)}async getArtifact(i){return await new p(this.owner,this.repo,i).get()}async getArtifactZipBlob(i){return await new p(this.owner,this.repo,i).downloadBlob()}async getBranches(){return await new W(this.owner,this.repo).getList()}async getBranch(i){return await new Q(this.owner,this.repo,i).get()}async getReferences(i){return await new w(this.owner,this.repo).getMatchingList(i)}async getBranchReferences(){return await new w(this.owner,this.repo).getMatchingList("heads/")}async getTagReferences(){return await new w(this.owner,this.repo).getMatchingList("tags/")}async postReference(...i){return await new w(this.owner,this.repo).post(...i)}async getReference(i){return await new a(this.owner,this.repo,i).get()}async getBranchReference(i){return await new a(this.owner,this.repo,`heads/${i}`).get()}async getTagReference(i){return await new a(this.owner,this.repo,`tags/${i}`).get()}async patchReference(i,...d){return await new o(this.owner,this.repo,i).patch(...d)}async deleteReference(i){return await new o(this.owner,this.repo,i).delete()}async getBlob(i){return await new t(this.owner,this.repo,i).get()}async postBlob(...i){return await new r(this.owner,this.repo).post(...i)}async getTree(i){return await new st(this.owner,this.repo,i).get()}async postTree(...i){return await new rt(this.owner,this.repo).post(...i)}async getIssues(i){return await new c(this.owner,this.repo).getList(i)}async postIssue(...i){return await new c(this.owner,this.repo).post(...i)}issue(i){return new s(this.owner,this.repo,i)}async getIssue(i){return await new s(this.owner,this.repo,i).get()}async patchIssue(i,...d){return await new s(this.owner,this.repo,i).patch(...d)}async getPulls(i){return await new G(this.owner,this.repo).getList(i)}async postPull(...i){return await new G(this.owner,this.repo).post(...i)}pull(i){return new b(this.owner,this.repo,i)}async getPull(i){return await new b(this.owner,this.repo,i).get()}async patchPull(i,...d){return await new b(this.owner,this.repo,i).patch(...d)}async getReleases(i){return await new E(this.owner,this.repo).getList(i)}async postRelease(...i){return await new E(this.owner,this.repo).post(...i)}async getLatestRelease(){return await new tt(this.owner,this.repo).get()}async postCommit(...i){return await new Y(this.owner,this.repo).post(...i)}async getRuns(i){return await new et(this.owner,this.repo).getList(i)}}}function V(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user`}}}function X(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/orgs`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function Z(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/repos`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function K(e){return{GitHubMyIssues:H(e),GitHubOrganizationRepositories:T(e),GitHubRepository:D(e),GitHubRepositoryIssues:f(e),GitHubUser:V(e),GitHubUserOrganizations:X(e),GitHubUserRepositories:Z(e)}}var R=class{token;githubClasses;constructor(t){this.token=t,this.githubClasses=K(t)}async getMe(){return await new this.githubClasses.GitHubUser().get()}async getMyOrganizations(){let{GitHubUserOrganizations:t,GitHubOrganizationRepositories:r}=this.githubClasses;return(await new t().getList()).map(o=>({...o,async getRepositories(){return await new r(o.login).getList()}}))}async getMyRepositories(){let{GitHubUserRepositories:t,GitHubRepositoryIssues:r}=this.githubClasses;return(await new t().getList()).map(o=>({...o,async getIssues(){return await new r(o.owner.login,o.name).getList()},async postIssue(...a){return await new r(o.owner.login,o.name).post(...a)}}))}async getMyIssues(){let{GitHubMyIssues:t}=this.githubClasses;return await new t().getList()}repo(t,r){let{GitHubRepository:s}=this.githubClasses;return new s(t,r)}};return ut(gt);})();
|
|
1
|
+
"use strict";var GitHubRepoJs=(()=>{var b=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var pt=Object.prototype.hasOwnProperty;var s=(e,t)=>b(e,"name",{value:t,configurable:!0});var at=(e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})},ut=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of nt(t))!pt.call(e,n)&&n!==r&&b(e,n,{get:()=>t[n],enumerable:!(i=ot(t,n))||i.enumerable});return e};var ct=e=>ut(b({},"__esModule",{value:!0}),e);var dt={};at(dt,{GitHubFacade:()=>G});async function h(e,t){let r=t??10,i=[],n=1;for(;;){let{resultItems:u}=await e({per_page:r,page:n});if(i.push(u),u.length<r)break;n++}return i.flat()}s(h,"loopPages");var gt="https://api.github.com",c=class{static{s(this,"GitHubApiBase")}token;constructor(t){this.token=t}get apiOrigin(){return gt}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(t){return await h(async({per_page:r,page:i})=>{let n=new URL(this.apiEndpoint),u={...t??{},per_page:r,page:i};for(let[a,g]of Object.entries(u))n.searchParams.append(a,`${g}`);return{resultItems:await fetch(n,{headers:this.requestHeaders,cache:"no-store"}).then(a=>{if(!a.ok)throw new Error(a.statusText,{cause:{response:a}});return a.json()})}},this.pageSizeForRequest)}async getList(t){let r=new URL(this.apiEndpoint);for(let[n,u]of Object.entries(t??{}))r.searchParams.append(n,`${u}`);return await fetch(r,{headers:this.requestHeaders,cache:"no-store"}).then(n=>{if(!n.ok)throw new Error(n.statusText,{cause:{response:n}});return n.json()})}async get(){return await fetch(this.apiEndpoint,{headers:this.requestHeaders,cache:"no-store"}).then(r=>{if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return r.json()})}async post(t){return await fetch(this.apiEndpoint,{method:"POST",headers:this.requestHeaders,body:JSON.stringify(t)}).then(i=>{if(!i.ok)throw new Error(i.statusText,{cause:{response:i}});return i.json()})}async patch(t){return await fetch(this.apiEndpoint,{method:"PATCH",headers:this.requestHeaders,body:JSON.stringify(t)}).then(i=>{if(!i.ok)throw new Error(i.statusText,{cause:{response:i}});return i.json()})}async delete(){let t=await fetch(this.apiEndpoint,{method:"DELETE",headers:this.requestHeaders});if(!t.ok)throw new Error(t.statusText,{cause:{response:t}})}},p=class extends c{static{s(this,"GitHubRepoApiBase")}owner;repo;constructor(t,r,i){super(t),this.owner=r,this.repo=i}},y=class extends p{static{s(this,"GitHubIssueApiBase")}issueNumber;constructor(t,r,i,n){super(t,r,i),this.issueNumber=n}},d=class extends p{static{s(this,"GitHubPullApiBase")}pullNumber;constructor(t,r,i,n){super(t,r,i),this.pullNumber=n}};function T(e){return class extends c{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(T,"readyGitHubMyIssues");function $(e){return class extends c{org;constructor(t){super(e),this.org=t}get apiEndpoint(){return`${this.apiOrigin}/orgs/${this.org}/repos`}}}s($,"readyGitHubOrganizationRepositories");function x(e){return class extends p{fileSha;constructor(t,r,i){super(e,t,r),this.fileSha=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs/${this.fileSha}`}}}s(x,"readyGitHubBlob");function P(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs`}}}s(P,"readyGitHubBlobs");function O(e){return class extends y{constructor(t,r,i){super(e,t,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}/comments`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(O,"readyGitHubIssueComments");function B(e){let t=O(e);return class extends y{constructor(r,i,n){super(e,r,i,n)}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(...r){return await new t(this.owner,this.repo,this.issueNumber).post(...r)}}}s(B,"readyGitHubIssue");function I(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts`}get pageSizeForRequest(){return 100}async getList(t){return await h(async({per_page:r,page:i})=>{let n=new URL(this.apiEndpoint),u={...t??{},per_page:r,page:i};for(let[a,g]of Object.entries(u))n.searchParams.append(a,`${g}`);return{resultItems:await fetch(n,{headers:this.requestHeaders,cache:"no-store"}).then(async a=>{if(!a.ok)throw new Error(a.statusText,{cause:{response:a}});let{artifacts:g}=await a.json();return g})}},this.pageSizeForRequest)}}}s(I,"readyGitHubRepositoryArtifacts");function A(e){return class extends p{artifactId;constructor(t,r,i){super(e,t,r),this.artifactId=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts/${this.artifactId}`}async downloadBlob(){let t=`${this.apiEndpoint}/zip`,r=await fetch(t,{headers:this.requestHeaders,cache:"no-store"});if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return await r.blob()}}}s(A,"readyGitHubRepositoryArtifact");function q(e){return class extends p{branch;constructor(t,r,i){super(e,t,r),this.branch=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches/${this.branch}`}}}s(q,"readyGitHubRepositoryBranch");function L(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(L,"readyGitHubRepositoryBranches");function S(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/commits`}}}s(S,"readyGitHubRepositoryCommits");function l(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(l,"readyGitHubRepositoryIssues");function v(e){return class extends p{ref;constructor(t,r,i){super(e,t,r),this.ref=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs/${this.ref}`}}}s(v,"readyGitHubReference");function C(e){return class extends p{ref;constructor(t,r,i){super(e,t,r),this.ref=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/ref/${this.ref}`}}}s(C,"readyGitHubReferenceForGet");function k(e){return class extends d{constructor(t,r,i){super(e,t,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/commits`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(k,"readyGitHubPullCommits");function z(e){return class extends d{constructor(t,r,i){super(e,t,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/requested_reviewers`}}}s(z,"readyGitHubPullReviewers");function _(e){let t=k(e),r=z(e);return class extends d{constructor(i,n,u){super(e,i,n,u)}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 r(this.owner,this.repo,this.pullNumber).get()}async postReviewers(...i){return await new r(this.owner,this.repo,this.pullNumber).post(...i)}}}s(_,"readyGitHubRepositoryPull");function N(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(N,"readyGitHubRepositoryPulls");function U(e){class t extends p{static{s(this,"GitHubRepositoryMatchingReferences")}refName;constructor(i,n,u){super(e,i,n),this.refName=u}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/matching-refs/${this.refName}`}}return class extends p{constructor(r,i){super(e,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs`}async getMatchingList(r){return await new t(this.owner,this.repo,r).getList()}}}s(U,"readyGitHubRepositoryReferences");function F(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(F,"readyGitHubRepositoryReleases");function M(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases/latest`}}}s(M,"readyGitHubRepositoryLatestRelease");function j(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/runs`}get pageSizeForRequest(){return 100}async getList(t){return await h(async({per_page:r,page:i})=>{let n=new URL(this.apiEndpoint),u={...t??{},per_page:r,page:i};for(let[a,g]of Object.entries(u))n.searchParams.append(a,`${g}`);return{resultItems:await fetch(n,{headers:this.requestHeaders,cache:"no-store"}).then(async a=>{if(!a.ok)throw new Error(a.statusText,{cause:{response:a}});let{workflow_runs:g}=await a.json();return g})}},this.pageSizeForRequest)}}}s(j,"readyGitHubRepositoryRuns");function J(e){return class extends p{treeSha;constructor(t,r,i){super(e,t,r),this.treeSha=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees/${this.treeSha}?recursive=true`}}}s(J,"readyGitHubTree");function D(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees`}}}s(D,"readyGitHubRepositoryTrees");function V(e){let t=x(e),r=P(e),i=B(e),n=v(e),u=C(e),w=I(e),a=A(e),g=l(e),W=q(e),Y=L(e),tt=S(e),R=_(e),E=N(e),f=U(e),H=F(e),et=M(e),rt=j(e),st=D(e),it=J(e);return class extends p{constructor(o,m){super(e,o,m)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}`}async getArtifacts(o){return await new w(this.owner,this.repo).getList(o)}async getArtifact(o){return await new a(this.owner,this.repo,o).get()}async getArtifactZipBlob(o){return await new a(this.owner,this.repo,o).downloadBlob()}async getBranches(){return await new Y(this.owner,this.repo).getList()}async getBranch(o){return await new W(this.owner,this.repo,o).get()}async getReferences(o){return await new f(this.owner,this.repo).getMatchingList(o)}async getBranchReferences(){return await new f(this.owner,this.repo).getMatchingList("heads/")}async getTagReferences(){return await new f(this.owner,this.repo).getMatchingList("tags/")}async postReference(...o){return await new f(this.owner,this.repo).post(...o)}async getReference(o){return await new u(this.owner,this.repo,o).get()}async getBranchReference(o){return await new u(this.owner,this.repo,`heads/${o}`).get()}async getTagReference(o){return await new u(this.owner,this.repo,`tags/${o}`).get()}async patchReference(o,...m){return await new n(this.owner,this.repo,o).patch(...m)}async deleteReference(o){return await new n(this.owner,this.repo,o).delete()}async getBlob(o){return await new t(this.owner,this.repo,o).get()}async postBlob(...o){return await new r(this.owner,this.repo).post(...o)}async getTree(o){return await new it(this.owner,this.repo,o).get()}async postTree(...o){return await new st(this.owner,this.repo).post(...o)}async getIssues(o){return await new g(this.owner,this.repo).getList(o)}async postIssue(...o){return await new g(this.owner,this.repo).post(...o)}issue(o){return new i(this.owner,this.repo,o)}async getIssue(o){return await new i(this.owner,this.repo,o).get()}async patchIssue(o,...m){return await new i(this.owner,this.repo,o).patch(...m)}async getPulls(o){return await new E(this.owner,this.repo).getList(o)}async postPull(...o){return await new E(this.owner,this.repo).post(...o)}pull(o){return new R(this.owner,this.repo,o)}async getPull(o){return await new R(this.owner,this.repo,o).get()}async patchPull(o,...m){return await new R(this.owner,this.repo,o).patch(...m)}async getReleases(o){return await new H(this.owner,this.repo).getList(o)}async postRelease(...o){return await new H(this.owner,this.repo).post(...o)}async getLatestRelease(){return await new et(this.owner,this.repo).get()}async postCommit(...o){return await new tt(this.owner,this.repo).post(...o)}async getRuns(o){return await new rt(this.owner,this.repo).getList(o)}}}s(V,"readyGitHubRepository");function X(e){return class extends c{static{s(this,"GitHubUser")}constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user`}}}s(X,"readyGitHubUser");function Z(e){return class extends c{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/orgs`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(Z,"readyGitHubUserOrganizations");function K(e){return class extends c{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/repos`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(K,"readyGitHubUserRepositories");function Q(e){return{GitHubMyIssues:T(e),GitHubOrganizationRepositories:$(e),GitHubRepository:V(e),GitHubRepositoryIssues:l(e),GitHubUser:X(e),GitHubUserOrganizations:Z(e),GitHubUserRepositories:K(e)}}s(Q,"readyGitHubClasses");var G=class{static{s(this,"GitHubFacade")}token;githubClasses;constructor(t){this.token=t,this.githubClasses=Q(t)}async getMe(){return await new this.githubClasses.GitHubUser().get()}async getMyOrganizations(){let{GitHubUserOrganizations:t,GitHubOrganizationRepositories:r}=this.githubClasses;return(await new t().getList()).map(n=>({...n,async getRepositories(){return await new r(n.login).getList()}}))}async getMyRepositories(){let{GitHubUserRepositories:t,GitHubRepositoryIssues:r}=this.githubClasses;return(await new t().getList()).map(n=>({...n,async getIssues(){return await new r(n.owner.login,n.name).getList()},async postIssue(...u){return await new r(n.owner.login,n.name).post(...u)}}))}async getMyIssues(){let{GitHubMyIssues:t}=this.githubClasses;return await new t().getList()}repo(t,r){let{GitHubRepository:i}=this.githubClasses;return new i(t,r)}};return ct(dt);})();
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
async function m(e,t){let r=t??10,s=[],n=1;for(;;){let{resultItems:a}=await e({per_page:r,page:n});if(s.push(a),a.length<r)break;n++}return s.flat()}var st="https://api.github.com",u=class{token;constructor(t){this.token=t}get apiOrigin(){return st}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(t){return await m(async({per_page:r,page:s})=>{let n=new URL(this.apiEndpoint),a={...t??{},per_page:r,page:s};for(let[p,c]of Object.entries(a))n.searchParams.append(p,`${c}`);return{resultItems:await fetch(n,{headers:this.requestHeaders,cache:"no-store"}).then(p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});return p.json()})}},this.pageSizeForRequest)}async getList(t){let r=new URL(this.apiEndpoint);for(let[n,a]of Object.entries(t??{}))r.searchParams.append(n,`${a}`);return await fetch(r,{headers:this.requestHeaders,cache:"no-store"}).then(n=>{if(!n.ok)throw new Error(n.statusText,{cause:{response:n}});return n.json()})}async get(){return await fetch(this.apiEndpoint,{headers:this.requestHeaders,cache:"no-store"}).then(r=>{if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return r.json()})}async post(t){return await fetch(this.apiEndpoint,{method:"POST",headers:this.requestHeaders,body:JSON.stringify(t)}).then(s=>{if(!s.ok)throw new Error(s.statusText,{cause:{response:s}});return s.json()})}async patch(t){return await fetch(this.apiEndpoint,{method:"PATCH",headers:this.requestHeaders,body:JSON.stringify(t)}).then(s=>{if(!s.ok)throw new Error(s.statusText,{cause:{response:s}});return s.json()})}async delete(){let t=await fetch(this.apiEndpoint,{method:"DELETE",headers:this.requestHeaders});if(!t.ok)throw new Error(t.statusText,{cause:{response:t}})}},o=class extends u{owner;repo;constructor(t,r,s){super(t),this.owner=r,this.repo=s}},h=class extends o{issueNumber;constructor(t,r,s,n){super(t,r,s),this.issueNumber=n}},g=class extends o{pullNumber;constructor(t,r,s,n){super(t,r,s),this.pullNumber=n}};function G(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function E(e){return class extends u{org;constructor(t){super(e),this.org=t}get apiEndpoint(){return`${this.apiOrigin}/orgs/${this.org}/repos`}}}function H(e){return class extends o{fileSha;constructor(t,r,s){super(e,t,r),this.fileSha=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs/${this.fileSha}`}}}function T(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs`}}}function $(e){return class extends h{constructor(t,r,s){super(e,t,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}/comments`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function x(e){let t=$(e);return class extends h{constructor(r,s,n){super(e,r,s,n)}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(...r){return await new t(this.owner,this.repo,this.issueNumber).post(...r)}}}function P(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts`}get pageSizeForRequest(){return 100}async getList(t){return await m(async({per_page:r,page:s})=>{let n=new URL(this.apiEndpoint),a={...t??{},per_page:r,page:s};for(let[p,c]of Object.entries(a))n.searchParams.append(p,`${c}`);return{resultItems:await fetch(n,{headers:this.requestHeaders,cache:"no-store"}).then(async p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});let{artifacts:c}=await p.json();return c})}},this.pageSizeForRequest)}}}function O(e){return class extends o{artifactId;constructor(t,r,s){super(e,t,r),this.artifactId=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts/${this.artifactId}`}async downloadBlob(){let t=`${this.apiEndpoint}/zip`,r=await fetch(t,{headers:this.requestHeaders,cache:"no-store"});if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return await r.blob()}}}function B(e){return class extends o{branch;constructor(t,r,s){super(e,t,r),this.branch=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches/${this.branch}`}}}function I(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function A(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/commits`}}}function f(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function q(e){return class extends o{ref;constructor(t,r,s){super(e,t,r),this.ref=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs/${this.ref}`}}}function L(e){return class extends o{ref;constructor(t,r,s){super(e,t,r),this.ref=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/ref/${this.ref}`}}}function S(e){return class extends g{constructor(t,r,s){super(e,t,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/commits`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function v(e){return class extends g{constructor(t,r,s){super(e,t,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/requested_reviewers`}}}function C(e){let t=S(e),r=v(e);return class extends g{constructor(s,n,a){super(e,s,n,a)}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 r(this.owner,this.repo,this.pullNumber).get()}async postReviewers(...s){return await new r(this.owner,this.repo,this.pullNumber).post(...s)}}}function k(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function z(e){class t extends o{refName;constructor(s,n,a){super(e,s,n),this.refName=a}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/matching-refs/${this.refName}`}}return class extends o{constructor(r,s){super(e,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs`}async getMatchingList(r){return await new t(this.owner,this.repo,r).getList()}}}function _(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function N(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases/latest`}}}function U(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/runs`}get pageSizeForRequest(){return 100}async getList(t){return await m(async({per_page:r,page:s})=>{let n=new URL(this.apiEndpoint),a={...t??{},per_page:r,page:s};for(let[p,c]of Object.entries(a))n.searchParams.append(p,`${c}`);return{resultItems:await fetch(n,{headers:this.requestHeaders,cache:"no-store"}).then(async p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});let{workflow_runs:c}=await p.json();return c})}},this.pageSizeForRequest)}}}function F(e){return class extends o{treeSha;constructor(t,r,s){super(e,t,r),this.treeSha=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees/${this.treeSha}?recursive=true`}}}function M(e){return class extends o{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees`}}}function j(e){let t=H(e),r=T(e),s=x(e),n=q(e),a=L(e),y=P(e),p=O(e),c=f(e),K=B(e),Q=I(e),W=A(e),b=C(e),l=k(e),w=z(e),R=_(e),Y=N(e),tt=U(e),et=M(e),rt=F(e);return class extends o{constructor(i,d){super(e,i,d)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}`}async getArtifacts(i){return await new y(this.owner,this.repo).getList(i)}async getArtifact(i){return await new p(this.owner,this.repo,i).get()}async getArtifactZipBlob(i){return await new p(this.owner,this.repo,i).downloadBlob()}async getBranches(){return await new Q(this.owner,this.repo).getList()}async getBranch(i){return await new K(this.owner,this.repo,i).get()}async getReferences(i){return await new w(this.owner,this.repo).getMatchingList(i)}async getBranchReferences(){return await new w(this.owner,this.repo).getMatchingList("heads/")}async getTagReferences(){return await new w(this.owner,this.repo).getMatchingList("tags/")}async postReference(...i){return await new w(this.owner,this.repo).post(...i)}async getReference(i){return await new a(this.owner,this.repo,i).get()}async getBranchReference(i){return await new a(this.owner,this.repo,`heads/${i}`).get()}async getTagReference(i){return await new a(this.owner,this.repo,`tags/${i}`).get()}async patchReference(i,...d){return await new n(this.owner,this.repo,i).patch(...d)}async deleteReference(i){return await new n(this.owner,this.repo,i).delete()}async getBlob(i){return await new t(this.owner,this.repo,i).get()}async postBlob(...i){return await new r(this.owner,this.repo).post(...i)}async getTree(i){return await new rt(this.owner,this.repo,i).get()}async postTree(...i){return await new et(this.owner,this.repo).post(...i)}async getIssues(i){return await new c(this.owner,this.repo).getList(i)}async postIssue(...i){return await new c(this.owner,this.repo).post(...i)}issue(i){return new s(this.owner,this.repo,i)}async getIssue(i){return await new s(this.owner,this.repo,i).get()}async patchIssue(i,...d){return await new s(this.owner,this.repo,i).patch(...d)}async getPulls(i){return await new l(this.owner,this.repo).getList(i)}async postPull(...i){return await new l(this.owner,this.repo).post(...i)}pull(i){return new b(this.owner,this.repo,i)}async getPull(i){return await new b(this.owner,this.repo,i).get()}async patchPull(i,...d){return await new b(this.owner,this.repo,i).patch(...d)}async getReleases(i){return await new R(this.owner,this.repo).getList(i)}async postRelease(...i){return await new R(this.owner,this.repo).post(...i)}async getLatestRelease(){return await new Y(this.owner,this.repo).get()}async postCommit(...i){return await new W(this.owner,this.repo).post(...i)}async getRuns(i){return await new tt(this.owner,this.repo).getList(i)}}}function J(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user`}}}function D(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/orgs`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function V(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/repos`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function X(e){return{GitHubMyIssues:G(e),GitHubOrganizationRepositories:E(e),GitHubRepository:j(e),GitHubRepositoryIssues:f(e),GitHubUser:J(e),GitHubUserOrganizations:D(e),GitHubUserRepositories:V(e)}}var Z=class{token;githubClasses;constructor(t){this.token=t,this.githubClasses=X(t)}async getMe(){return await new this.githubClasses.GitHubUser().get()}async getMyOrganizations(){let{GitHubUserOrganizations:t,GitHubOrganizationRepositories:r}=this.githubClasses;return(await new t().getList()).map(n=>({...n,async getRepositories(){return await new r(n.login).getList()}}))}async getMyRepositories(){let{GitHubUserRepositories:t,GitHubRepositoryIssues:r}=this.githubClasses;return(await new t().getList()).map(n=>({...n,async getIssues(){return await new r(n.owner.login,n.name).getList()},async postIssue(...a){return await new r(n.owner.login,n.name).post(...a)}}))}async getMyIssues(){let{GitHubMyIssues:t}=this.githubClasses;return await new t().getList()}repo(t,r){let{GitHubRepository:s}=this.githubClasses;return new s(t,r)}};export{Z as GitHubFacade};
|
|
1
|
+
var it=Object.defineProperty;var s=(e,t)=>it(e,"name",{value:t,configurable:!0});async function h(e,t){let r=t??10,i=[],p=1;for(;;){let{resultItems:u}=await e({per_page:r,page:p});if(i.push(u),u.length<r)break;p++}return i.flat()}s(h,"loopPages");var ot="https://api.github.com",c=class{static{s(this,"GitHubApiBase")}token;constructor(t){this.token=t}get apiOrigin(){return ot}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(t){return await h(async({per_page:r,page:i})=>{let p=new URL(this.apiEndpoint),u={...t??{},per_page:r,page:i};for(let[a,g]of Object.entries(u))p.searchParams.append(a,`${g}`);return{resultItems:await fetch(p,{headers:this.requestHeaders,cache:"no-store"}).then(a=>{if(!a.ok)throw new Error(a.statusText,{cause:{response:a}});return a.json()})}},this.pageSizeForRequest)}async getList(t){let r=new URL(this.apiEndpoint);for(let[p,u]of Object.entries(t??{}))r.searchParams.append(p,`${u}`);return await fetch(r,{headers:this.requestHeaders,cache:"no-store"}).then(p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});return p.json()})}async get(){return await fetch(this.apiEndpoint,{headers:this.requestHeaders,cache:"no-store"}).then(r=>{if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return r.json()})}async post(t){return await fetch(this.apiEndpoint,{method:"POST",headers:this.requestHeaders,body:JSON.stringify(t)}).then(i=>{if(!i.ok)throw new Error(i.statusText,{cause:{response:i}});return i.json()})}async patch(t){return await fetch(this.apiEndpoint,{method:"PATCH",headers:this.requestHeaders,body:JSON.stringify(t)}).then(i=>{if(!i.ok)throw new Error(i.statusText,{cause:{response:i}});return i.json()})}async delete(){let t=await fetch(this.apiEndpoint,{method:"DELETE",headers:this.requestHeaders});if(!t.ok)throw new Error(t.statusText,{cause:{response:t}})}},n=class extends c{static{s(this,"GitHubRepoApiBase")}owner;repo;constructor(t,r,i){super(t),this.owner=r,this.repo=i}},y=class extends n{static{s(this,"GitHubIssueApiBase")}issueNumber;constructor(t,r,i,p){super(t,r,i),this.issueNumber=p}},d=class extends n{static{s(this,"GitHubPullApiBase")}pullNumber;constructor(t,r,i,p){super(t,r,i),this.pullNumber=p}};function E(e){return class extends c{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(E,"readyGitHubMyIssues");function H(e){return class extends c{org;constructor(t){super(e),this.org=t}get apiEndpoint(){return`${this.apiOrigin}/orgs/${this.org}/repos`}}}s(H,"readyGitHubOrganizationRepositories");function T(e){return class extends n{fileSha;constructor(t,r,i){super(e,t,r),this.fileSha=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs/${this.fileSha}`}}}s(T,"readyGitHubBlob");function $(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs`}}}s($,"readyGitHubBlobs");function x(e){return class extends y{constructor(t,r,i){super(e,t,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}/comments`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(x,"readyGitHubIssueComments");function P(e){let t=x(e);return class extends y{constructor(r,i,p){super(e,r,i,p)}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(...r){return await new t(this.owner,this.repo,this.issueNumber).post(...r)}}}s(P,"readyGitHubIssue");function O(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts`}get pageSizeForRequest(){return 100}async getList(t){return await h(async({per_page:r,page:i})=>{let p=new URL(this.apiEndpoint),u={...t??{},per_page:r,page:i};for(let[a,g]of Object.entries(u))p.searchParams.append(a,`${g}`);return{resultItems:await fetch(p,{headers:this.requestHeaders,cache:"no-store"}).then(async a=>{if(!a.ok)throw new Error(a.statusText,{cause:{response:a}});let{artifacts:g}=await a.json();return g})}},this.pageSizeForRequest)}}}s(O,"readyGitHubRepositoryArtifacts");function B(e){return class extends n{artifactId;constructor(t,r,i){super(e,t,r),this.artifactId=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts/${this.artifactId}`}async downloadBlob(){let t=`${this.apiEndpoint}/zip`,r=await fetch(t,{headers:this.requestHeaders,cache:"no-store"});if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return await r.blob()}}}s(B,"readyGitHubRepositoryArtifact");function I(e){return class extends n{branch;constructor(t,r,i){super(e,t,r),this.branch=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches/${this.branch}`}}}s(I,"readyGitHubRepositoryBranch");function A(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(A,"readyGitHubRepositoryBranches");function q(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/commits`}}}s(q,"readyGitHubRepositoryCommits");function b(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(b,"readyGitHubRepositoryIssues");function L(e){return class extends n{ref;constructor(t,r,i){super(e,t,r),this.ref=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs/${this.ref}`}}}s(L,"readyGitHubReference");function S(e){return class extends n{ref;constructor(t,r,i){super(e,t,r),this.ref=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/ref/${this.ref}`}}}s(S,"readyGitHubReferenceForGet");function v(e){return class extends d{constructor(t,r,i){super(e,t,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/commits`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(v,"readyGitHubPullCommits");function C(e){return class extends d{constructor(t,r,i){super(e,t,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/requested_reviewers`}}}s(C,"readyGitHubPullReviewers");function k(e){let t=v(e),r=C(e);return class extends d{constructor(i,p,u){super(e,i,p,u)}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 r(this.owner,this.repo,this.pullNumber).get()}async postReviewers(...i){return await new r(this.owner,this.repo,this.pullNumber).post(...i)}}}s(k,"readyGitHubRepositoryPull");function z(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(z,"readyGitHubRepositoryPulls");function _(e){class t extends n{static{s(this,"GitHubRepositoryMatchingReferences")}refName;constructor(i,p,u){super(e,i,p),this.refName=u}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/matching-refs/${this.refName}`}}return class extends n{constructor(r,i){super(e,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs`}async getMatchingList(r){return await new t(this.owner,this.repo,r).getList()}}}s(_,"readyGitHubRepositoryReferences");function N(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(N,"readyGitHubRepositoryReleases");function U(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases/latest`}}}s(U,"readyGitHubRepositoryLatestRelease");function F(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/runs`}get pageSizeForRequest(){return 100}async getList(t){return await h(async({per_page:r,page:i})=>{let p=new URL(this.apiEndpoint),u={...t??{},per_page:r,page:i};for(let[a,g]of Object.entries(u))p.searchParams.append(a,`${g}`);return{resultItems:await fetch(p,{headers:this.requestHeaders,cache:"no-store"}).then(async a=>{if(!a.ok)throw new Error(a.statusText,{cause:{response:a}});let{workflow_runs:g}=await a.json();return g})}},this.pageSizeForRequest)}}}s(F,"readyGitHubRepositoryRuns");function M(e){return class extends n{treeSha;constructor(t,r,i){super(e,t,r),this.treeSha=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees/${this.treeSha}?recursive=true`}}}s(M,"readyGitHubTree");function j(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees`}}}s(j,"readyGitHubRepositoryTrees");function J(e){let t=T(e),r=$(e),i=P(e),p=L(e),u=S(e),w=O(e),a=B(e),g=b(e),Q=I(e),W=A(e),Y=q(e),l=k(e),R=z(e),f=_(e),G=N(e),tt=U(e),et=F(e),rt=j(e),st=M(e);return class extends n{constructor(o,m){super(e,o,m)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}`}async getArtifacts(o){return await new w(this.owner,this.repo).getList(o)}async getArtifact(o){return await new a(this.owner,this.repo,o).get()}async getArtifactZipBlob(o){return await new a(this.owner,this.repo,o).downloadBlob()}async getBranches(){return await new W(this.owner,this.repo).getList()}async getBranch(o){return await new Q(this.owner,this.repo,o).get()}async getReferences(o){return await new f(this.owner,this.repo).getMatchingList(o)}async getBranchReferences(){return await new f(this.owner,this.repo).getMatchingList("heads/")}async getTagReferences(){return await new f(this.owner,this.repo).getMatchingList("tags/")}async postReference(...o){return await new f(this.owner,this.repo).post(...o)}async getReference(o){return await new u(this.owner,this.repo,o).get()}async getBranchReference(o){return await new u(this.owner,this.repo,`heads/${o}`).get()}async getTagReference(o){return await new u(this.owner,this.repo,`tags/${o}`).get()}async patchReference(o,...m){return await new p(this.owner,this.repo,o).patch(...m)}async deleteReference(o){return await new p(this.owner,this.repo,o).delete()}async getBlob(o){return await new t(this.owner,this.repo,o).get()}async postBlob(...o){return await new r(this.owner,this.repo).post(...o)}async getTree(o){return await new st(this.owner,this.repo,o).get()}async postTree(...o){return await new rt(this.owner,this.repo).post(...o)}async getIssues(o){return await new g(this.owner,this.repo).getList(o)}async postIssue(...o){return await new g(this.owner,this.repo).post(...o)}issue(o){return new i(this.owner,this.repo,o)}async getIssue(o){return await new i(this.owner,this.repo,o).get()}async patchIssue(o,...m){return await new i(this.owner,this.repo,o).patch(...m)}async getPulls(o){return await new R(this.owner,this.repo).getList(o)}async postPull(...o){return await new R(this.owner,this.repo).post(...o)}pull(o){return new l(this.owner,this.repo,o)}async getPull(o){return await new l(this.owner,this.repo,o).get()}async patchPull(o,...m){return await new l(this.owner,this.repo,o).patch(...m)}async getReleases(o){return await new G(this.owner,this.repo).getList(o)}async postRelease(...o){return await new G(this.owner,this.repo).post(...o)}async getLatestRelease(){return await new tt(this.owner,this.repo).get()}async postCommit(...o){return await new Y(this.owner,this.repo).post(...o)}async getRuns(o){return await new et(this.owner,this.repo).getList(o)}}}s(J,"readyGitHubRepository");function D(e){return class extends c{static{s(this,"GitHubUser")}constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user`}}}s(D,"readyGitHubUser");function V(e){return class extends c{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/orgs`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(V,"readyGitHubUserOrganizations");function X(e){return class extends c{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/repos`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(X,"readyGitHubUserRepositories");function Z(e){return{GitHubMyIssues:E(e),GitHubOrganizationRepositories:H(e),GitHubRepository:J(e),GitHubRepositoryIssues:b(e),GitHubUser:D(e),GitHubUserOrganizations:V(e),GitHubUserRepositories:X(e)}}s(Z,"readyGitHubClasses");var K=class{static{s(this,"GitHubFacade")}token;githubClasses;constructor(t){this.token=t,this.githubClasses=Z(t)}async getMe(){return await new this.githubClasses.GitHubUser().get()}async getMyOrganizations(){let{GitHubUserOrganizations:t,GitHubOrganizationRepositories:r}=this.githubClasses;return(await new t().getList()).map(p=>({...p,async getRepositories(){return await new r(p.login).getList()}}))}async getMyRepositories(){let{GitHubUserRepositories:t,GitHubRepositoryIssues:r}=this.githubClasses;return(await new t().getList()).map(p=>({...p,async getIssues(){return await new r(p.owner.login,p.name).getList()},async postIssue(...u){return await new r(p.owner.login,p.name).post(...u)}}))}async getMyIssues(){let{GitHubMyIssues:t}=this.githubClasses;return await new t().getList()}repo(t,r){let{GitHubRepository:i}=this.githubClasses;return new i(t,r)}};export{K as GitHubFacade};
|
package/dist/repl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function h(e,t){let r=t??10,s=[],o=1;for(;;){let{resultItems:a}=await e({per_page:r,page:o});if(s.push(a),a.length<r)break;o++}return s.flat()}var it="https://api.github.com",u=class{token;constructor(t){this.token=t}get apiOrigin(){return it}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(t){return await h(async({per_page:r,page:s})=>{let o=new URL(this.apiEndpoint),a={...t??{},per_page:r,page:s};for(let[p,c]of Object.entries(a))o.searchParams.append(p,`${c}`);return{resultItems:await fetch(o,{headers:this.requestHeaders,cache:"no-store"}).then(p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});return p.json()})}},this.pageSizeForRequest)}async getList(t){let r=new URL(this.apiEndpoint);for(let[o,a]of Object.entries(t??{}))r.searchParams.append(o,`${a}`);return await fetch(r,{headers:this.requestHeaders,cache:"no-store"}).then(o=>{if(!o.ok)throw new Error(o.statusText,{cause:{response:o}});return o.json()})}async get(){return await fetch(this.apiEndpoint,{headers:this.requestHeaders,cache:"no-store"}).then(r=>{if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return r.json()})}async post(t){return await fetch(this.apiEndpoint,{method:"POST",headers:this.requestHeaders,body:JSON.stringify(t)}).then(s=>{if(!s.ok)throw new Error(s.statusText,{cause:{response:s}});return s.json()})}async patch(t){return await fetch(this.apiEndpoint,{method:"PATCH",headers:this.requestHeaders,body:JSON.stringify(t)}).then(s=>{if(!s.ok)throw new Error(s.statusText,{cause:{response:s}});return s.json()})}async delete(){let t=await fetch(this.apiEndpoint,{method:"DELETE",headers:this.requestHeaders});if(!t.ok)throw new Error(t.statusText,{cause:{response:t}})}},n=class extends u{owner;repo;constructor(t,r,s){super(t),this.owner=r,this.repo=s}},y=class extends n{issueNumber;constructor(t,r,s,o){super(t,r,s),this.issueNumber=o}},g=class extends n{pullNumber;constructor(t,r,s,o){super(t,r,s),this.pullNumber=o}};function H(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function E(e){return class extends u{org;constructor(t){super(e),this.org=t}get apiEndpoint(){return`${this.apiOrigin}/orgs/${this.org}/repos`}}}function T(e){return class extends n{fileSha;constructor(t,r,s){super(e,t,r),this.fileSha=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs/${this.fileSha}`}}}function $(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs`}}}function x(e){return class extends y{constructor(t,r,s){super(e,t,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}/comments`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function P(e){let t=x(e);return class extends y{constructor(r,s,o){super(e,r,s,o)}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(...r){return await new t(this.owner,this.repo,this.issueNumber).post(...r)}}}function O(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts`}get pageSizeForRequest(){return 100}async getList(t){return await h(async({per_page:r,page:s})=>{let o=new URL(this.apiEndpoint),a={...t??{},per_page:r,page:s};for(let[p,c]of Object.entries(a))o.searchParams.append(p,`${c}`);return{resultItems:await fetch(o,{headers:this.requestHeaders,cache:"no-store"}).then(async p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});let{artifacts:c}=await p.json();return c})}},this.pageSizeForRequest)}}}function B(e){return class extends n{artifactId;constructor(t,r,s){super(e,t,r),this.artifactId=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts/${this.artifactId}`}async downloadBlob(){let t=`${this.apiEndpoint}/zip`,r=await fetch(t,{headers:this.requestHeaders,cache:"no-store"});if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return await r.blob()}}}function I(e){return class extends n{branch;constructor(t,r,s){super(e,t,r),this.branch=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches/${this.branch}`}}}function A(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function q(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/commits`}}}function f(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function L(e){return class extends n{ref;constructor(t,r,s){super(e,t,r),this.ref=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs/${this.ref}`}}}function S(e){return class extends n{ref;constructor(t,r,s){super(e,t,r),this.ref=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/ref/${this.ref}`}}}function v(e){return class extends g{constructor(t,r,s){super(e,t,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/commits`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function C(e){return class extends g{constructor(t,r,s){super(e,t,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/requested_reviewers`}}}function k(e){let t=v(e),r=C(e);return class extends g{constructor(s,o,a){super(e,s,o,a)}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 r(this.owner,this.repo,this.pullNumber).get()}async postReviewers(...s){return await new r(this.owner,this.repo,this.pullNumber).post(...s)}}}function z(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function _(e){class t extends n{refName;constructor(s,o,a){super(e,s,o),this.refName=a}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/matching-refs/${this.refName}`}}return class extends n{constructor(r,s){super(e,r,s)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs`}async getMatchingList(r){return await new t(this.owner,this.repo,r).getList()}}}function F(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function N(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases/latest`}}}function U(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/runs`}get pageSizeForRequest(){return 100}async getList(t){return await h(async({per_page:r,page:s})=>{let o=new URL(this.apiEndpoint),a={...t??{},per_page:r,page:s};for(let[p,c]of Object.entries(a))o.searchParams.append(p,`${c}`);return{resultItems:await fetch(o,{headers:this.requestHeaders,cache:"no-store"}).then(async p=>{if(!p.ok)throw new Error(p.statusText,{cause:{response:p}});let{workflow_runs:c}=await p.json();return c})}},this.pageSizeForRequest)}}}function M(e){return class extends n{treeSha;constructor(t,r,s){super(e,t,r),this.treeSha=s}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees/${this.treeSha}?recursive=true`}}}function j(e){return class extends n{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees`}}}function J(e){let t=T(e),r=$(e),s=P(e),o=L(e),a=S(e),d=O(e),p=B(e),c=f(e),Q=I(e),W=A(e),Y=q(e),l=k(e),R=z(e),w=_(e),G=F(e),tt=N(e),et=U(e),rt=j(e),st=M(e);return class extends n{constructor(i,m){super(e,i,m)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}`}async getArtifacts(i){return await new d(this.owner,this.repo).getList(i)}async getArtifact(i){return await new p(this.owner,this.repo,i).get()}async getArtifactZipBlob(i){return await new p(this.owner,this.repo,i).downloadBlob()}async getBranches(){return await new W(this.owner,this.repo).getList()}async getBranch(i){return await new Q(this.owner,this.repo,i).get()}async getReferences(i){return await new w(this.owner,this.repo).getMatchingList(i)}async getBranchReferences(){return await new w(this.owner,this.repo).getMatchingList("heads/")}async getTagReferences(){return await new w(this.owner,this.repo).getMatchingList("tags/")}async postReference(...i){return await new w(this.owner,this.repo).post(...i)}async getReference(i){return await new a(this.owner,this.repo,i).get()}async getBranchReference(i){return await new a(this.owner,this.repo,`heads/${i}`).get()}async getTagReference(i){return await new a(this.owner,this.repo,`tags/${i}`).get()}async patchReference(i,...m){return await new o(this.owner,this.repo,i).patch(...m)}async deleteReference(i){return await new o(this.owner,this.repo,i).delete()}async getBlob(i){return await new t(this.owner,this.repo,i).get()}async postBlob(...i){return await new r(this.owner,this.repo).post(...i)}async getTree(i){return await new st(this.owner,this.repo,i).get()}async postTree(...i){return await new rt(this.owner,this.repo).post(...i)}async getIssues(i){return await new c(this.owner,this.repo).getList(i)}async postIssue(...i){return await new c(this.owner,this.repo).post(...i)}issue(i){return new s(this.owner,this.repo,i)}async getIssue(i){return await new s(this.owner,this.repo,i).get()}async patchIssue(i,...m){return await new s(this.owner,this.repo,i).patch(...m)}async getPulls(i){return await new R(this.owner,this.repo).getList(i)}async postPull(...i){return await new R(this.owner,this.repo).post(...i)}pull(i){return new l(this.owner,this.repo,i)}async getPull(i){return await new l(this.owner,this.repo,i).get()}async patchPull(i,...m){return await new l(this.owner,this.repo,i).patch(...m)}async getReleases(i){return await new G(this.owner,this.repo).getList(i)}async postRelease(...i){return await new G(this.owner,this.repo).post(...i)}async getLatestRelease(){return await new tt(this.owner,this.repo).get()}async postCommit(...i){return await new Y(this.owner,this.repo).post(...i)}async getRuns(i){return await new et(this.owner,this.repo).getList(i)}}}function K(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user`}}}function D(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/orgs`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function V(e){return class extends u{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/repos`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}function X(e){return{GitHubMyIssues:H(e),GitHubOrganizationRepositories:E(e),GitHubRepository:J(e),GitHubRepositoryIssues:f(e),GitHubUser:K(e),GitHubUserOrganizations:D(e),GitHubUserRepositories:V(e)}}var b=class{token;githubClasses;constructor(t){this.token=t,this.githubClasses=X(t)}async getMe(){return await new this.githubClasses.GitHubUser().get()}async getMyOrganizations(){let{GitHubUserOrganizations:t,GitHubOrganizationRepositories:r}=this.githubClasses;return(await new t().getList()).map(o=>({...o,async getRepositories(){return await new r(o.login).getList()}}))}async getMyRepositories(){let{GitHubUserRepositories:t,GitHubRepositoryIssues:r}=this.githubClasses;return(await new t().getList()).map(o=>({...o,async getIssues(){return await new r(o.owner.login,o.name).getList()},async postIssue(...a){return await new r(o.owner.login,o.name).post(...a)}}))}async getMyIssues(){let{GitHubMyIssues:t}=this.githubClasses;return await new t().getList()}repo(t,r){let{GitHubRepository:s}=this.githubClasses;return new s(t,r)}};import{start as ot}from"repl";import{readFile as nt}from"fs/promises";import*as Z from"path";import pt from"assert";async function at(e,t){await new Function("{github}",`return new Promise(async (resolve) => {
|
|
2
|
-
${await
|
|
1
|
+
var ot=Object.defineProperty;var s=(e,t)=>ot(e,"name",{value:t,configurable:!0});async function y(e,t){let r=t??10,i=[],n=1;for(;;){let{resultItems:u}=await e({per_page:r,page:n});if(i.push(u),u.length<r)break;n++}return i.flat()}s(y,"loopPages");var nt="https://api.github.com",c=class{static{s(this,"GitHubApiBase")}token;constructor(t){this.token=t}get apiOrigin(){return nt}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(t){return await y(async({per_page:r,page:i})=>{let n=new URL(this.apiEndpoint),u={...t??{},per_page:r,page:i};for(let[a,g]of Object.entries(u))n.searchParams.append(a,`${g}`);return{resultItems:await fetch(n,{headers:this.requestHeaders,cache:"no-store"}).then(a=>{if(!a.ok)throw new Error(a.statusText,{cause:{response:a}});return a.json()})}},this.pageSizeForRequest)}async getList(t){let r=new URL(this.apiEndpoint);for(let[n,u]of Object.entries(t??{}))r.searchParams.append(n,`${u}`);return await fetch(r,{headers:this.requestHeaders,cache:"no-store"}).then(n=>{if(!n.ok)throw new Error(n.statusText,{cause:{response:n}});return n.json()})}async get(){return await fetch(this.apiEndpoint,{headers:this.requestHeaders,cache:"no-store"}).then(r=>{if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return r.json()})}async post(t){return await fetch(this.apiEndpoint,{method:"POST",headers:this.requestHeaders,body:JSON.stringify(t)}).then(i=>{if(!i.ok)throw new Error(i.statusText,{cause:{response:i}});return i.json()})}async patch(t){return await fetch(this.apiEndpoint,{method:"PATCH",headers:this.requestHeaders,body:JSON.stringify(t)}).then(i=>{if(!i.ok)throw new Error(i.statusText,{cause:{response:i}});return i.json()})}async delete(){let t=await fetch(this.apiEndpoint,{method:"DELETE",headers:this.requestHeaders});if(!t.ok)throw new Error(t.statusText,{cause:{response:t}})}},p=class extends c{static{s(this,"GitHubRepoApiBase")}owner;repo;constructor(t,r,i){super(t),this.owner=r,this.repo=i}},w=class extends p{static{s(this,"GitHubIssueApiBase")}issueNumber;constructor(t,r,i,n){super(t,r,i),this.issueNumber=n}},m=class extends p{static{s(this,"GitHubPullApiBase")}pullNumber;constructor(t,r,i,n){super(t,r,i),this.pullNumber=n}};function E(e){return class extends c{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(E,"readyGitHubMyIssues");function T(e){return class extends c{org;constructor(t){super(e),this.org=t}get apiEndpoint(){return`${this.apiOrigin}/orgs/${this.org}/repos`}}}s(T,"readyGitHubOrganizationRepositories");function $(e){return class extends p{fileSha;constructor(t,r,i){super(e,t,r),this.fileSha=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs/${this.fileSha}`}}}s($,"readyGitHubBlob");function x(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/blobs`}}}s(x,"readyGitHubBlobs");function P(e){return class extends w{constructor(t,r,i){super(e,t,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues/${this.issueNumber}/comments`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(P,"readyGitHubIssueComments");function O(e){let t=P(e);return class extends w{constructor(r,i,n){super(e,r,i,n)}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(...r){return await new t(this.owner,this.repo,this.issueNumber).post(...r)}}}s(O,"readyGitHubIssue");function B(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts`}get pageSizeForRequest(){return 100}async getList(t){return await y(async({per_page:r,page:i})=>{let n=new URL(this.apiEndpoint),u={...t??{},per_page:r,page:i};for(let[a,g]of Object.entries(u))n.searchParams.append(a,`${g}`);return{resultItems:await fetch(n,{headers:this.requestHeaders,cache:"no-store"}).then(async a=>{if(!a.ok)throw new Error(a.statusText,{cause:{response:a}});let{artifacts:g}=await a.json();return g})}},this.pageSizeForRequest)}}}s(B,"readyGitHubRepositoryArtifacts");function I(e){return class extends p{artifactId;constructor(t,r,i){super(e,t,r),this.artifactId=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/artifacts/${this.artifactId}`}async downloadBlob(){let t=`${this.apiEndpoint}/zip`,r=await fetch(t,{headers:this.requestHeaders,cache:"no-store"});if(!r.ok)throw new Error(r.statusText,{cause:{response:r}});return await r.blob()}}}s(I,"readyGitHubRepositoryArtifact");function A(e){return class extends p{branch;constructor(t,r,i){super(e,t,r),this.branch=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches/${this.branch}`}}}s(A,"readyGitHubRepositoryBranch");function q(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/branches`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(q,"readyGitHubRepositoryBranches");function L(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/commits`}}}s(L,"readyGitHubRepositoryCommits");function b(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/issues`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(b,"readyGitHubRepositoryIssues");function S(e){return class extends p{ref;constructor(t,r,i){super(e,t,r),this.ref=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs/${this.ref}`}}}s(S,"readyGitHubReference");function v(e){return class extends p{ref;constructor(t,r,i){super(e,t,r),this.ref=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/ref/${this.ref}`}}}s(v,"readyGitHubReferenceForGet");function C(e){return class extends m{constructor(t,r,i){super(e,t,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/commits`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(C,"readyGitHubPullCommits");function k(e){return class extends m{constructor(t,r,i){super(e,t,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls/${this.pullNumber}/requested_reviewers`}}}s(k,"readyGitHubPullReviewers");function z(e){let t=C(e),r=k(e);return class extends m{constructor(i,n,u){super(e,i,n,u)}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 r(this.owner,this.repo,this.pullNumber).get()}async postReviewers(...i){return await new r(this.owner,this.repo,this.pullNumber).post(...i)}}}s(z,"readyGitHubRepositoryPull");function _(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/pulls`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(_,"readyGitHubRepositoryPulls");function F(e){class t extends p{static{s(this,"GitHubRepositoryMatchingReferences")}refName;constructor(i,n,u){super(e,i,n),this.refName=u}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/matching-refs/${this.refName}`}}return class extends p{constructor(r,i){super(e,r,i)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/refs`}async getMatchingList(r){return await new t(this.owner,this.repo,r).getList()}}}s(F,"readyGitHubRepositoryReferences");function N(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(N,"readyGitHubRepositoryReleases");function U(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/releases/latest`}}}s(U,"readyGitHubRepositoryLatestRelease");function M(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/actions/runs`}get pageSizeForRequest(){return 100}async getList(t){return await y(async({per_page:r,page:i})=>{let n=new URL(this.apiEndpoint),u={...t??{},per_page:r,page:i};for(let[a,g]of Object.entries(u))n.searchParams.append(a,`${g}`);return{resultItems:await fetch(n,{headers:this.requestHeaders,cache:"no-store"}).then(async a=>{if(!a.ok)throw new Error(a.statusText,{cause:{response:a}});let{workflow_runs:g}=await a.json();return g})}},this.pageSizeForRequest)}}}s(M,"readyGitHubRepositoryRuns");function j(e){return class extends p{treeSha;constructor(t,r,i){super(e,t,r),this.treeSha=i}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees/${this.treeSha}?recursive=true`}}}s(j,"readyGitHubTree");function J(e){return class extends p{constructor(t,r){super(e,t,r)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}/git/trees`}}}s(J,"readyGitHubRepositoryTrees");function K(e){let t=$(e),r=x(e),i=O(e),n=S(e),u=v(e),h=B(e),a=I(e),g=b(e),W=A(e),Y=q(e),tt=L(e),R=z(e),G=_(e),f=F(e),H=N(e),et=U(e),rt=M(e),st=J(e),it=j(e);return class extends p{constructor(o,d){super(e,o,d)}get apiEndpoint(){return`${this.apiOrigin}/repos/${this.owner}/${this.repo}`}async getArtifacts(o){return await new h(this.owner,this.repo).getList(o)}async getArtifact(o){return await new a(this.owner,this.repo,o).get()}async getArtifactZipBlob(o){return await new a(this.owner,this.repo,o).downloadBlob()}async getBranches(){return await new Y(this.owner,this.repo).getList()}async getBranch(o){return await new W(this.owner,this.repo,o).get()}async getReferences(o){return await new f(this.owner,this.repo).getMatchingList(o)}async getBranchReferences(){return await new f(this.owner,this.repo).getMatchingList("heads/")}async getTagReferences(){return await new f(this.owner,this.repo).getMatchingList("tags/")}async postReference(...o){return await new f(this.owner,this.repo).post(...o)}async getReference(o){return await new u(this.owner,this.repo,o).get()}async getBranchReference(o){return await new u(this.owner,this.repo,`heads/${o}`).get()}async getTagReference(o){return await new u(this.owner,this.repo,`tags/${o}`).get()}async patchReference(o,...d){return await new n(this.owner,this.repo,o).patch(...d)}async deleteReference(o){return await new n(this.owner,this.repo,o).delete()}async getBlob(o){return await new t(this.owner,this.repo,o).get()}async postBlob(...o){return await new r(this.owner,this.repo).post(...o)}async getTree(o){return await new it(this.owner,this.repo,o).get()}async postTree(...o){return await new st(this.owner,this.repo).post(...o)}async getIssues(o){return await new g(this.owner,this.repo).getList(o)}async postIssue(...o){return await new g(this.owner,this.repo).post(...o)}issue(o){return new i(this.owner,this.repo,o)}async getIssue(o){return await new i(this.owner,this.repo,o).get()}async patchIssue(o,...d){return await new i(this.owner,this.repo,o).patch(...d)}async getPulls(o){return await new G(this.owner,this.repo).getList(o)}async postPull(...o){return await new G(this.owner,this.repo).post(...o)}pull(o){return new R(this.owner,this.repo,o)}async getPull(o){return await new R(this.owner,this.repo,o).get()}async patchPull(o,...d){return await new R(this.owner,this.repo,o).patch(...d)}async getReleases(o){return await new H(this.owner,this.repo).getList(o)}async postRelease(...o){return await new H(this.owner,this.repo).post(...o)}async getLatestRelease(){return await new et(this.owner,this.repo).get()}async postCommit(...o){return await new tt(this.owner,this.repo).post(...o)}async getRuns(o){return await new rt(this.owner,this.repo).getList(o)}}}s(K,"readyGitHubRepository");function D(e){return class extends c{static{s(this,"GitHubUser")}constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user`}}}s(D,"readyGitHubUser");function V(e){return class extends c{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/orgs`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(V,"readyGitHubUserOrganizations");function X(e){return class extends c{constructor(){super(e)}get apiEndpoint(){return`${this.apiOrigin}/user/repos`}get pageSizeForRequest(){return 100}async getList(t){return await this.getPagedList(t)}}}s(X,"readyGitHubUserRepositories");function Z(e){return{GitHubMyIssues:E(e),GitHubOrganizationRepositories:T(e),GitHubRepository:K(e),GitHubRepositoryIssues:b(e),GitHubUser:D(e),GitHubUserOrganizations:V(e),GitHubUserRepositories:X(e)}}s(Z,"readyGitHubClasses");var l=class{static{s(this,"GitHubFacade")}token;githubClasses;constructor(t){this.token=t,this.githubClasses=Z(t)}async getMe(){return await new this.githubClasses.GitHubUser().get()}async getMyOrganizations(){let{GitHubUserOrganizations:t,GitHubOrganizationRepositories:r}=this.githubClasses;return(await new t().getList()).map(n=>({...n,async getRepositories(){return await new r(n.login).getList()}}))}async getMyRepositories(){let{GitHubUserRepositories:t,GitHubRepositoryIssues:r}=this.githubClasses;return(await new t().getList()).map(n=>({...n,async getIssues(){return await new r(n.owner.login,n.name).getList()},async postIssue(...u){return await new r(n.owner.login,n.name).post(...u)}}))}async getMyIssues(){let{GitHubMyIssues:t}=this.githubClasses;return await new t().getList()}repo(t,r){let{GitHubRepository:i}=this.githubClasses;return new i(t,r)}};import{start as pt}from"repl";import{readFile as at}from"fs/promises";import*as Q from"path";import ut from"assert";async function ct(e,t){await new Function("{github}",`return new Promise(async (resolve) => {
|
|
2
|
+
${await at(e,{encoding:"utf8"})}
|
|
3
3
|
resolve();
|
|
4
|
-
});`)({github:t})}async function
|
|
4
|
+
});`)({github:t})}s(ct,"executeScriptFile");async function gt(){let e=process.env.GITHUB_TOKEN;ut(e!=null&&e!=="","GITHUB_TOKEN environment variable is not set");let t=new l(e),[r,i,n]=process.argv,u=Q.resolve(process.cwd(),`/scripts/${n}`);if(n!=null){await ct(u,t);return}let h=pt({prompt:"github> "});h.context.github=t}s(gt,"main");gt().catch(console.error);
|
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.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@octokit/types": "16.0.0",
|
|
36
36
|
"@tsconfig/node24": "24.0.4",
|
|
37
|
-
"@types/node": "25.
|
|
37
|
+
"@types/node": "25.6.0",
|
|
38
38
|
"tsup": "8.5.1",
|
|
39
39
|
"tsx": "4.21.0",
|
|
40
40
|
"typescript": "5.9.3",
|
|
41
|
-
"vitest": "4.1.
|
|
41
|
+
"vitest": "4.1.4"
|
|
42
42
|
}
|
|
43
43
|
}
|