@openally/github.sdk 1.0.0
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/.all-contributorsrc +16 -0
- package/.editorconfig +14 -0
- package/.github/dependabot.yml +25 -0
- package/.github/workflows/codeql.yml +78 -0
- package/.github/workflows/node.js.yml +52 -0
- package/.github/workflows/publish.yml +29 -0
- package/.github/workflows/scorecards.yml +76 -0
- package/LICENSE +21 -0
- package/README.md +106 -0
- package/SECURITY.md +5 -0
- package/docs/api/ApiEndpoint.md +37 -0
- package/docs/api/GithubClient.md +50 -0
- package/docs/api/repos.md +97 -0
- package/docs/api/users.md +76 -0
- package/eslint.config.mjs +3 -0
- package/package.json +50 -0
- package/src/api/repos.ts +74 -0
- package/src/api/users.ts +47 -0
- package/src/class/ApiEndpoint.ts +105 -0
- package/src/class/GithubClient.ts +31 -0
- package/src/class/HttpLinkParser.ts +17 -0
- package/src/class/createApiProxy.ts +9 -0
- package/src/index.ts +5 -0
- package/src/types.ts +37 -0
- package/test/ApiEndpoint.spec.ts +301 -0
- package/test/GithubClient.spec.ts +166 -0
- package/test/HttpLinkParser.spec.ts +78 -0
- package/test/createApiProxy.spec.ts +58 -0
- package/test/repos.spec.ts +221 -0
- package/test/users.spec.ts +159 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"README.md"
|
|
4
|
+
],
|
|
5
|
+
"imageSize": 100,
|
|
6
|
+
"commit": false,
|
|
7
|
+
"contributors": [],
|
|
8
|
+
"contributorsPerLine": 7,
|
|
9
|
+
"projectName": "github.sdk",
|
|
10
|
+
"projectOwner": "OpenAlly",
|
|
11
|
+
"repoType": "github",
|
|
12
|
+
"repoHost": "https://github.com",
|
|
13
|
+
"skipCi": true,
|
|
14
|
+
"commitType": "docs",
|
|
15
|
+
"commitConvention": "angular"
|
|
16
|
+
}
|
package/.editorconfig
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Editor configuration, see https://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
end_of_line = lf
|
|
11
|
+
|
|
12
|
+
[*.md]
|
|
13
|
+
max_line_length = off
|
|
14
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: github-actions
|
|
4
|
+
directory: /
|
|
5
|
+
schedule:
|
|
6
|
+
interval: monthly
|
|
7
|
+
cooldown:
|
|
8
|
+
default-days: 5
|
|
9
|
+
groups:
|
|
10
|
+
github-actions:
|
|
11
|
+
patterns:
|
|
12
|
+
- "*"
|
|
13
|
+
|
|
14
|
+
- package-ecosystem: npm
|
|
15
|
+
directory: /
|
|
16
|
+
versioning-strategy: widen
|
|
17
|
+
schedule:
|
|
18
|
+
interval: weekly
|
|
19
|
+
cooldown:
|
|
20
|
+
default-days: 5
|
|
21
|
+
groups:
|
|
22
|
+
dependencies:
|
|
23
|
+
dependency-type: "production"
|
|
24
|
+
development-dependencies:
|
|
25
|
+
dependency-type: "development"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
+
# to commit it to your repository.
|
|
3
|
+
#
|
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
+
# or to provide custom queries or build logic.
|
|
6
|
+
#
|
|
7
|
+
# ******** NOTE ********
|
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
+
# supported CodeQL languages.
|
|
11
|
+
#
|
|
12
|
+
name: "CodeQL"
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
branches: ["main"]
|
|
17
|
+
pull_request:
|
|
18
|
+
# The branches below must be a subset of the branches above
|
|
19
|
+
branches: ["main"]
|
|
20
|
+
schedule:
|
|
21
|
+
- cron: "0 0 * * 1"
|
|
22
|
+
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
|
|
26
|
+
jobs:
|
|
27
|
+
analyze:
|
|
28
|
+
name: Analyze
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
permissions:
|
|
31
|
+
actions: read
|
|
32
|
+
contents: read
|
|
33
|
+
security-events: write
|
|
34
|
+
|
|
35
|
+
strategy:
|
|
36
|
+
fail-fast: false
|
|
37
|
+
matrix:
|
|
38
|
+
language: ["typescript"]
|
|
39
|
+
# CodeQL supports [ $supported-codeql-languages ]
|
|
40
|
+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
|
41
|
+
|
|
42
|
+
steps:
|
|
43
|
+
- name: Harden Runner
|
|
44
|
+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
|
45
|
+
with:
|
|
46
|
+
egress-policy: audit
|
|
47
|
+
|
|
48
|
+
- name: Checkout repository
|
|
49
|
+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
50
|
+
|
|
51
|
+
# Initializes the CodeQL tools for scanning.
|
|
52
|
+
- name: Initialize CodeQL
|
|
53
|
+
uses: github/codeql-action/init@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
|
|
54
|
+
with:
|
|
55
|
+
languages: ${{ matrix.language }}
|
|
56
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
57
|
+
# By default, queries listed here will override any specified in a config file.
|
|
58
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
59
|
+
|
|
60
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
61
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
62
|
+
- name: Autobuild
|
|
63
|
+
uses: github/codeql-action/autobuild@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
|
|
64
|
+
|
|
65
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
66
|
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
67
|
+
|
|
68
|
+
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
|
69
|
+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
|
70
|
+
|
|
71
|
+
# - run: |
|
|
72
|
+
# echo "Run, Build Application using script"
|
|
73
|
+
# ./location_of_script_within_repo/buildscript.sh
|
|
74
|
+
|
|
75
|
+
- name: Perform CodeQL Analysis
|
|
76
|
+
uses: github/codeql-action/analyze@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
|
|
77
|
+
with:
|
|
78
|
+
category: "/language:${{matrix.language}}"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "main" ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ "main" ]
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
|
|
20
|
+
strategy:
|
|
21
|
+
matrix:
|
|
22
|
+
node-version: [24.x]
|
|
23
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
24
|
+
|
|
25
|
+
steps:
|
|
26
|
+
- name: Harden Runner
|
|
27
|
+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
|
28
|
+
with:
|
|
29
|
+
egress-policy: audit
|
|
30
|
+
|
|
31
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
32
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
33
|
+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
|
34
|
+
with:
|
|
35
|
+
node-version: ${{ matrix.node-version }}
|
|
36
|
+
- run: npm install --ignore-scripts
|
|
37
|
+
- run: npm run build --if-present
|
|
38
|
+
- run: npm test
|
|
39
|
+
automerge:
|
|
40
|
+
if: >
|
|
41
|
+
github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]'
|
|
42
|
+
needs:
|
|
43
|
+
- build
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
permissions:
|
|
46
|
+
contents: write
|
|
47
|
+
pull-requests: write
|
|
48
|
+
steps:
|
|
49
|
+
- name: Merge Dependabot PR
|
|
50
|
+
uses: fastify/github-action-merge-dependabot@1b2ed42db8f9d81a46bac83adedfc03eb5149dff # v3.11.2
|
|
51
|
+
with:
|
|
52
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Publish Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write # Required for OIDC
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
|
19
|
+
with:
|
|
20
|
+
node-version: '24.x'
|
|
21
|
+
registry-url: 'https://registry.npmjs.org'
|
|
22
|
+
|
|
23
|
+
# Ensure npm 11.5.1 or later is installed
|
|
24
|
+
- name: Update npm
|
|
25
|
+
run: npm install -g npm@latest
|
|
26
|
+
- run: npm install --ignore-scripts
|
|
27
|
+
- run: npm run build --if-present
|
|
28
|
+
- run: npm test
|
|
29
|
+
- run: npm publish
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub. They are provided
|
|
2
|
+
# by a third-party and are governed by separate terms of service, privacy
|
|
3
|
+
# policy, and support documentation.
|
|
4
|
+
|
|
5
|
+
name: Scorecard supply-chain security
|
|
6
|
+
on:
|
|
7
|
+
# For Branch-Protection check. Only the default branch is supported. See
|
|
8
|
+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
|
|
9
|
+
branch_protection_rule:
|
|
10
|
+
# To guarantee Maintained check is occasionally updated. See
|
|
11
|
+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
|
|
12
|
+
schedule:
|
|
13
|
+
- cron: '20 7 * * 2'
|
|
14
|
+
push:
|
|
15
|
+
branches: ["main"]
|
|
16
|
+
|
|
17
|
+
# Declare default permissions as read only.
|
|
18
|
+
permissions: read-all
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
analysis:
|
|
22
|
+
name: Scorecard analysis
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
permissions:
|
|
25
|
+
# Needed to upload the results to code-scanning dashboard.
|
|
26
|
+
security-events: write
|
|
27
|
+
# Needed to publish results and get a badge (see publish_results below).
|
|
28
|
+
id-token: write
|
|
29
|
+
contents: read
|
|
30
|
+
actions: read
|
|
31
|
+
|
|
32
|
+
steps:
|
|
33
|
+
- name: Harden Runner
|
|
34
|
+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
|
35
|
+
with:
|
|
36
|
+
egress-policy: audit
|
|
37
|
+
|
|
38
|
+
- name: "Checkout code"
|
|
39
|
+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
40
|
+
with:
|
|
41
|
+
persist-credentials: false
|
|
42
|
+
|
|
43
|
+
- name: "Run analysis"
|
|
44
|
+
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
|
45
|
+
with:
|
|
46
|
+
results_file: results.sarif
|
|
47
|
+
results_format: sarif
|
|
48
|
+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
|
|
49
|
+
# - you want to enable the Branch-Protection check on a *public* repository, or
|
|
50
|
+
# - you are installing Scorecards on a *private* repository
|
|
51
|
+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
|
|
52
|
+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
|
|
53
|
+
|
|
54
|
+
# Public repositories:
|
|
55
|
+
# - Publish results to OpenSSF REST API for easy access by consumers
|
|
56
|
+
# - Allows the repository to include the Scorecard badge.
|
|
57
|
+
# - See https://github.com/ossf/scorecard-action#publishing-results.
|
|
58
|
+
# For private repositories:
|
|
59
|
+
# - `publish_results` will always be set to `false`, regardless
|
|
60
|
+
# of the value entered here.
|
|
61
|
+
publish_results: true
|
|
62
|
+
|
|
63
|
+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
|
64
|
+
# format to the repository Actions tab.
|
|
65
|
+
- name: "Upload artifact"
|
|
66
|
+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
|
67
|
+
with:
|
|
68
|
+
name: SARIF file
|
|
69
|
+
path: results.sarif
|
|
70
|
+
retention-days: 5
|
|
71
|
+
|
|
72
|
+
# Upload the results to GitHub's code scanning dashboard.
|
|
73
|
+
- name: "Upload to code-scanning"
|
|
74
|
+
uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
|
|
75
|
+
with:
|
|
76
|
+
sarif_file: results.sarif
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenAlly
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<p align="center"><h1 align="center">
|
|
2
|
+
Github.SDK
|
|
3
|
+
</h1></p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
Opiniated Node.js Github SDK
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://github.com/OpenAlly/github.sdk">
|
|
11
|
+
<img src="https://img.shields.io/github/package-json/v/OpenAlly/github.sdk?style=for-the-badge" alt="npm version">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/OpenAlly/github.sdk">
|
|
14
|
+
<img src="https://img.shields.io/github/license/OpenAlly/github.sdk?style=for-the-badge" alt="license">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://api.securityscorecards.dev/projects/github.com/OpenAlly/github.sdk">
|
|
17
|
+
<img src="https://api.securityscorecards.dev/projects/github.com/OpenAlly/github.sdk/badge?style=for-the-badge" alt="ossf scorecard">
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://github.com/OpenAlly/github.sdk/actions?query=workflow%3A%22Node.js+CI%22">
|
|
20
|
+
<img src="https://img.shields.io/github/actions/workflow/status/OpenAlly/github.sdk/node.js.yml?style=for-the-badge" alt="github ci workflow">
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://github.com/OpenAlly/github.sdk">
|
|
23
|
+
<img src="https://img.shields.io/github/languages/code-size/OpenAlly/github.sdk?style=for-the-badge" alt="size">
|
|
24
|
+
</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
## 🚧 Requirements
|
|
28
|
+
|
|
29
|
+
- [Node.js](https://nodejs.org/en/) version 24 or higher
|
|
30
|
+
|
|
31
|
+
## 🚀 Getting Started
|
|
32
|
+
|
|
33
|
+
This package is available in the Node Package Repository and can be easily installed with [npm](https://doc.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
$ npm i @openally/github.sdk
|
|
37
|
+
# or
|
|
38
|
+
$ yarn add @openally/github.sdk
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 👀 Usage
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { GithubClient } from "@openally/github.sdk";
|
|
45
|
+
|
|
46
|
+
const github = new GithubClient({
|
|
47
|
+
token: process.env.GITHUB_TOKEN
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
for await (const pr of github.repos.nodejs.node.pulls().iterate()) {
|
|
51
|
+
console.log(pr.title);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const tags = await github.repos.OpenAlly["github.sdk"].tags().all();
|
|
55
|
+
|
|
56
|
+
const userRepos = await github.users.torvalds.repos().all();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 📚 API
|
|
60
|
+
|
|
61
|
+
- [ApiEndpoint](./docs/api/ApiEndpoint.md)
|
|
62
|
+
- [GithubClient](./docs/api/GithubClient.md)
|
|
63
|
+
|
|
64
|
+
Available GitHub APIs:
|
|
65
|
+
|
|
66
|
+
- [repos](./docs/api/repos.md)
|
|
67
|
+
- [users](./docs/api/users.md)
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
Proxy provides access to GitHub repository endpoints.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { repos } from "@openally/github.sdk";
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Via GithubClient (recommended for authenticated use)
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { GithubClient } from "@openally/github.sdk";
|
|
81
|
+
|
|
82
|
+
const { repos } = new GithubClient({
|
|
83
|
+
token: process.env.GITHUB_TOKEN
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Contributors ✨
|
|
88
|
+
|
|
89
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
90
|
+
[](#contributors-)
|
|
91
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
92
|
+
|
|
93
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
94
|
+
|
|
95
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
96
|
+
<!-- prettier-ignore-start -->
|
|
97
|
+
<!-- markdownlint-disable -->
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<!-- markdownlint-restore -->
|
|
101
|
+
<!-- prettier-ignore-end -->
|
|
102
|
+
|
|
103
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
MIT
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Reporting Security Issues
|
|
2
|
+
|
|
3
|
+
To report a security issue, please [publish a private security advisory](https://github.com/OpenAlly/github.sdk/security/advisories) with a description of the issue, the steps you took to create the issue, affected versions, and, if known, mitigations for the issue.
|
|
4
|
+
|
|
5
|
+
Our vulnerability management team will respond within one week. If the issue is confirmed as a vulnerability, we will open a Security Advisory and acknowledge your contributions as part of it. This project follows a 90 day disclosure timeline.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# ApiEndpoint
|
|
2
|
+
|
|
3
|
+
Every endpoint method returns an `ApiEndpoint<T>` instance. It transparently handles pagination, authentication, and data extraction.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { repos } from "@openally/github.sdk";
|
|
7
|
+
|
|
8
|
+
const endpoint = repos.nodejs.node.pulls()
|
|
9
|
+
.setBearerToken(process.env.GITHUB_TOKEN)
|
|
10
|
+
.setAgent("my-app/1.0.0");
|
|
11
|
+
|
|
12
|
+
// Stream items one by one across all pages
|
|
13
|
+
for await (const pr of endpoint.iterate()) {
|
|
14
|
+
console.log(pr.title);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Or collect everything at once
|
|
18
|
+
const allPRs = await endpoint.all();
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Methods
|
|
22
|
+
|
|
23
|
+
### `.setBearerToken(token: string): this`
|
|
24
|
+
|
|
25
|
+
Attaches a GitHub personal access token as a `Bearer` authorization header. Returns the instance for chaining.
|
|
26
|
+
|
|
27
|
+
### `.setAgent(userAgent: string): this`
|
|
28
|
+
|
|
29
|
+
Overrides the `User-Agent` request header. Returns the instance for chaining.
|
|
30
|
+
|
|
31
|
+
### `.iterate(): AsyncIterableIterator<T>`
|
|
32
|
+
|
|
33
|
+
Asynchronously iterates over all items across all pages. Pagination is handled transparently via GitHub's `Link` response header — you never need to manage page numbers or cursors manually.
|
|
34
|
+
|
|
35
|
+
### `.all(): Promise<T[]>`
|
|
36
|
+
|
|
37
|
+
Collects all pages and resolves with a flat array of every item.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# GithubClient
|
|
2
|
+
|
|
3
|
+
`GithubClient` is the recommended entry point when you need a shared token or `User-Agent` applied to every request without configuring each endpoint individually.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { GithubClient } from "@openally/github.sdk";
|
|
7
|
+
|
|
8
|
+
const github = new GithubClient({
|
|
9
|
+
token: process.env.GITHUB_TOKEN,
|
|
10
|
+
userAgent: "my-app/1.0.0"
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// Iterate over all open pull requests
|
|
14
|
+
for await (const pr of github.repos.OpenAlly["github.sdk"].pulls().iterate()) {
|
|
15
|
+
console.log(pr.title);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Collect all tags at once
|
|
19
|
+
const tags = await github.repos.OpenAlly["github.sdk"].tags().all();
|
|
20
|
+
|
|
21
|
+
// List all repositories for a user
|
|
22
|
+
const userRepos = await github.users.torvalds.repos().all();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Constructor
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
new GithubClient(options?: GithubClientOptions)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
interface GithubClientOptions {
|
|
33
|
+
/**
|
|
34
|
+
* GitHub personal access token sent as a Bearer authorization header.
|
|
35
|
+
* Required for private resources and to increase the API rate limit.
|
|
36
|
+
*/
|
|
37
|
+
token?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Value for the User-Agent request header.
|
|
41
|
+
* @default "@openally/github.sdk/1.0.0"
|
|
42
|
+
*/
|
|
43
|
+
userAgent?: string;
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Properties
|
|
48
|
+
|
|
49
|
+
- **`repos`** — `ReposProxy` — see [repos](./repos.md)
|
|
50
|
+
- **`users`** — `UsersProxy` — see [users](./users.md)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# repos
|
|
2
|
+
|
|
3
|
+
The `repos` proxy provides access to GitHub repository endpoints.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { repos } from "@openally/github.sdk";
|
|
7
|
+
|
|
8
|
+
// Collect all tags
|
|
9
|
+
const tags = await repos.OpenAlly["github.sdk"].tags().all();
|
|
10
|
+
|
|
11
|
+
// Stream pull requests page by page
|
|
12
|
+
for await (const pr of repos.nodejs.node.pulls().iterate()) {
|
|
13
|
+
console.log(pr.number, pr.title);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Stream workflow runs for a specific workflow file
|
|
17
|
+
for await (const run of repos.nodejs.node.workflowRuns("ci.yml").iterate()) {
|
|
18
|
+
console.log(run.id, run.status);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Collect all jobs for a specific run
|
|
22
|
+
const jobs = await repos.nodejs.node.runJobs(12345678).all();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Access pattern
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
repos[owner][repo].<method>()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
All methods return an [`ApiEndpoint<T>`](./ApiEndpoint.md) instance.
|
|
32
|
+
|
|
33
|
+
## Methods
|
|
34
|
+
|
|
35
|
+
### `.tags()`
|
|
36
|
+
|
|
37
|
+
Returns `ApiEndpoint<Tag>`.
|
|
38
|
+
|
|
39
|
+
Lists all tags for the repository.
|
|
40
|
+
|
|
41
|
+
> GitHub docs: [List repository tags](https://docs.github.com/en/rest/repos/repos#list-repository-tags)
|
|
42
|
+
|
|
43
|
+
### `.pulls()`
|
|
44
|
+
|
|
45
|
+
Returns `ApiEndpoint<PullRequest>`.
|
|
46
|
+
|
|
47
|
+
Lists pull requests.
|
|
48
|
+
|
|
49
|
+
> GitHub docs: [List pull requests](https://docs.github.com/en/rest/pulls/pulls#list-pull-requests)
|
|
50
|
+
|
|
51
|
+
### `.issues()`
|
|
52
|
+
|
|
53
|
+
Returns `ApiEndpoint<Issue>`.
|
|
54
|
+
|
|
55
|
+
Lists repository issues.
|
|
56
|
+
|
|
57
|
+
> GitHub docs: [List repository issues](https://docs.github.com/en/rest/issues/issues#list-repository-issues)
|
|
58
|
+
|
|
59
|
+
### `.commits()`
|
|
60
|
+
|
|
61
|
+
Returns `ApiEndpoint<Commit>`.
|
|
62
|
+
|
|
63
|
+
Lists commits.
|
|
64
|
+
|
|
65
|
+
> GitHub docs: [List commits](https://docs.github.com/en/rest/commits/commits#list-commits)
|
|
66
|
+
|
|
67
|
+
### `.workflows()`
|
|
68
|
+
|
|
69
|
+
Returns `ApiEndpoint<Workflow>`.
|
|
70
|
+
|
|
71
|
+
Lists all GitHub Actions workflows defined in the repository.
|
|
72
|
+
|
|
73
|
+
> GitHub docs: [List repository workflows](https://docs.github.com/en/rest/actions/workflows#list-repository-workflows)
|
|
74
|
+
|
|
75
|
+
### `.workflowRuns(workflowId: string | number)`
|
|
76
|
+
|
|
77
|
+
Returns `ApiEndpoint<WorkflowRun>`.
|
|
78
|
+
|
|
79
|
+
Lists runs for a specific workflow, identified by filename (e.g. `"ci.yml"`) or numeric ID.
|
|
80
|
+
|
|
81
|
+
> GitHub docs: [List workflow runs for a workflow](https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs-for-a-workflow)
|
|
82
|
+
|
|
83
|
+
### `.runJobs(runId: number)`
|
|
84
|
+
|
|
85
|
+
Returns `ApiEndpoint<Job>`.
|
|
86
|
+
|
|
87
|
+
Lists all jobs for a given workflow run.
|
|
88
|
+
|
|
89
|
+
> GitHub docs: [List jobs for a workflow run](https://docs.github.com/en/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run)
|
|
90
|
+
|
|
91
|
+
### `.runArtifacts(runId: number)`
|
|
92
|
+
|
|
93
|
+
Returns `ApiEndpoint<Artifact>`.
|
|
94
|
+
|
|
95
|
+
Lists all artifacts produced by a given workflow run.
|
|
96
|
+
|
|
97
|
+
> GitHub docs: [List workflow run artifacts](https://docs.github.com/en/rest/actions/artifacts#list-workflow-run-artifacts)
|